#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e5 + 1;
void solve() {
int n, m;
cin >> n >> m;
pii a[n];
for(int i = 0; i < n; i++){
cin >> a[i].ff >> a[i].ss;
}
sort(a, a + n);
int c[m];
for(int i = 0; i < m; i++){
cin >> c[i];
}
sort(c, c + m);
int l = 0, r = m + 1;
while(l + 1 < r){
int mid = l + (r - l) / 2;
int xl = 0, prev = 0;
multiset<int> ms;
bool ok = 1;
for(int i = m - mid; i < m; i++){
while(xl < n && a[xl].ff <= c[i])ms.insert(a[xl].ss), xl++;
while(!ms.empty() && prev > *ms.begin())ms.erase(ms.begin());
if(ms.empty()){
ok = 0;
break;
}
prev = *ms.begin();
ms.erase(ms.begin());
}
if(ok)l = mid;
else r = mid;
}
cout << l;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int times = 1;
//cin >> times;
for(int i = 1; i <= times; i++) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
2 ms |
348 KB |
Output is correct |
31 |
Correct |
2 ms |
496 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
2 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
2 ms |
348 KB |
Output is correct |
31 |
Correct |
2 ms |
496 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
2 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
348 KB |
Output is correct |
38 |
Correct |
135 ms |
6968 KB |
Output is correct |
39 |
Correct |
138 ms |
6748 KB |
Output is correct |
40 |
Correct |
175 ms |
7352 KB |
Output is correct |
41 |
Correct |
136 ms |
6856 KB |
Output is correct |
42 |
Correct |
36 ms |
4408 KB |
Output is correct |
43 |
Correct |
37 ms |
4412 KB |
Output is correct |
44 |
Correct |
164 ms |
6848 KB |
Output is correct |
45 |
Correct |
448 ms |
8460 KB |
Output is correct |
46 |
Correct |
349 ms |
8472 KB |
Output is correct |
47 |
Correct |
383 ms |
7484 KB |
Output is correct |
48 |
Correct |
356 ms |
7668 KB |
Output is correct |
49 |
Correct |
282 ms |
6460 KB |
Output is correct |
50 |
Correct |
239 ms |
6428 KB |
Output is correct |
51 |
Correct |
38 ms |
4404 KB |
Output is correct |
52 |
Correct |
36 ms |
4424 KB |
Output is correct |
53 |
Correct |
37 ms |
4436 KB |
Output is correct |
54 |
Correct |
227 ms |
9228 KB |
Output is correct |
55 |
Correct |
147 ms |
6724 KB |
Output is correct |
56 |
Correct |
33 ms |
5460 KB |
Output is correct |
57 |
Correct |
15 ms |
1628 KB |
Output is correct |
58 |
Correct |
88 ms |
7832 KB |
Output is correct |
59 |
Correct |
287 ms |
7816 KB |
Output is correct |
60 |
Correct |
14 ms |
1628 KB |
Output is correct |
61 |
Correct |
118 ms |
3908 KB |
Output is correct |
62 |
Correct |
295 ms |
6896 KB |
Output is correct |
63 |
Correct |
331 ms |
6876 KB |
Output is correct |
64 |
Correct |
311 ms |
6996 KB |
Output is correct |
65 |
Correct |
306 ms |
6936 KB |
Output is correct |
66 |
Correct |
312 ms |
6860 KB |
Output is correct |
67 |
Correct |
306 ms |
6864 KB |
Output is correct |
68 |
Correct |
285 ms |
6740 KB |
Output is correct |
69 |
Correct |
304 ms |
6996 KB |
Output is correct |
70 |
Correct |
284 ms |
6876 KB |
Output is correct |
71 |
Correct |
320 ms |
6876 KB |
Output is correct |
72 |
Correct |
236 ms |
6740 KB |
Output is correct |
73 |
Correct |
256 ms |
6740 KB |
Output is correct |