File tree Expand file tree Collapse file tree 3 files changed +141
-0
lines changed Expand file tree Collapse file tree 3 files changed +141
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #include < iostream>
3
+ using namespace std ;
4
+
5
+ #define mod 1000000007
6
+ #define all (x ) (x).begin(), (x).end()
7
+ typedef long long ll;
8
+
9
+
10
+ void subMain (){
11
+ ll n, m, h, t;
12
+ cin >> n >> m;
13
+ multiset<int , greater<int >> a;
14
+ while (n--){
15
+ cin >> h;
16
+ a.insert (h);
17
+ }
18
+ while (m--){
19
+ cin >> t;
20
+ auto it = a.lower_bound (t);
21
+ if (it==a.end ())
22
+ {
23
+ cout << " -1" << " \n " ;
24
+ }
25
+ else
26
+ {
27
+ cout << *it << " \n " ;
28
+ a.erase (it);
29
+ }
30
+ }
31
+
32
+ }
33
+
34
+ int32_t main (){
35
+
36
+
37
+ ios_base::sync_with_stdio (false );
38
+ cin.tie (0 ); cout.tie (0 );
39
+
40
+ /* ll t=1;
41
+ cin >> t;
42
+ while(t--){
43
+
44
+ }*/
45
+ subMain ();
46
+ return 0 ;
47
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #include < iostream>
3
+ using namespace std ;
4
+
5
+ #define mod 1000000007
6
+ #define all (x ) (x).begin(), (x).end()
7
+ typedef long long ll;
8
+
9
+
10
+ void subMain (){
11
+ vector<pair<ll,ll>> v;
12
+ ll n;
13
+ cin>>n;
14
+ for (ll i=0 ;i<n;i++){
15
+ ll a,c;
16
+ cin>>a>>c;
17
+ v.push_back ({c,a});
18
+ }
19
+ sort (v.begin (),v.end ());
20
+ ll curr=v[0 ].first ;
21
+ ll ans=1 ;
22
+ for (ll i=1 ;i<n;i++){
23
+ if (v[i].second >=curr){
24
+ curr=v[i].first ;
25
+ ans++;
26
+ }
27
+ }
28
+ cout<<ans<<" \n " ;
29
+ }
30
+
31
+ int32_t main (){
32
+
33
+
34
+ ios_base::sync_with_stdio (false );
35
+ cin.tie (0 ); cout.tie (0 );
36
+
37
+ /* ll t=1;
38
+ cin >> t;
39
+ while(t--){
40
+ subMain();
41
+ }*/
42
+ subMain ();
43
+
44
+ return 0 ;
45
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #include < iostream>
3
+ using namespace std ;
4
+
5
+ #define mod 1000000007
6
+ #define all (x ) (x).begin(), (x).end()
7
+ typedef long long ll;
8
+
9
+
10
+ void subMain (){
11
+ ll n, x, y;
12
+ cin >> n;
13
+ vector<pair<int , bool >> v;
14
+ for (ll i = 0 ; i < n; i++){
15
+ cin >> x >> y;
16
+ v.push_back (make_pair (x, true ));
17
+ v.push_back (make_pair (y, false ));
18
+ }
19
+ sort (all (v));
20
+ int ans = 0 , cnt = 0 ;
21
+ for (ll i = 0 ; i < v.size (); i++){
22
+ if (v[i].second ==true )
23
+ {
24
+ cnt++;
25
+ ans = max (ans, cnt);
26
+ }
27
+ else
28
+ {
29
+ cnt--;
30
+ }
31
+ }
32
+ cout << ans << " \n " ;
33
+ }
34
+
35
+ int32_t main (){
36
+
37
+
38
+ ios_base::sync_with_stdio (false );
39
+ cin.tie (0 ); cout.tie (0 );
40
+
41
+ /* ll t=1;
42
+ cin >> t;
43
+ while(t--){
44
+ subMain();
45
+ }*/
46
+ subMain ();
47
+
48
+ return 0 ;
49
+ }
You can’t perform that action at this time.
0 commit comments