#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int cur, x, n, c[N],m;
pair <int, int> a[N];
int check(int mid) {
cur = 1;
for (int i=m-mid+1; i <= m; i++) {
x = 0;
while (cur <= n) {
if (a[cur].second<=c[i]) {
x=1;
cur++;
break;
}
else cur++;
}
if (x==0){
return 0;
}
}
return 1;
}
int main(){
cin>>n>>m;
for (int i=1; i<=n; i++){
cin>>a[i].second; // zoma
cin>>a[i].first; // value
}
sort (a+1, a+n+1);
for (int i=1; i<=m; i++){
cin>>c[i];
}
sort (c+1, c+m+1);
int l=1;
int r=min(n,m);
int ans = 0;
while (l<=r) {
int mid=(l+r)/2;
if (check(mid)) {
ans=mid;
l=mid+1;
} else {
r=mid-1;
}
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
444 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
444 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
476 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 |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
2 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
444 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
476 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 |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
2 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
2 ms |
484 KB |
Output is correct |
38 |
Correct |
87 ms |
5940 KB |
Output is correct |
39 |
Correct |
90 ms |
5716 KB |
Output is correct |
40 |
Correct |
100 ms |
5964 KB |
Output is correct |
41 |
Correct |
86 ms |
5712 KB |
Output is correct |
42 |
Correct |
86 ms |
5712 KB |
Output is correct |
43 |
Correct |
91 ms |
5756 KB |
Output is correct |
44 |
Correct |
86 ms |
5716 KB |
Output is correct |
45 |
Correct |
87 ms |
5716 KB |
Output is correct |
46 |
Correct |
85 ms |
5848 KB |
Output is correct |
47 |
Correct |
78 ms |
5456 KB |
Output is correct |
48 |
Correct |
81 ms |
5456 KB |
Output is correct |
49 |
Correct |
70 ms |
5200 KB |
Output is correct |
50 |
Correct |
65 ms |
5200 KB |
Output is correct |
51 |
Correct |
83 ms |
5712 KB |
Output is correct |
52 |
Correct |
89 ms |
5712 KB |
Output is correct |
53 |
Correct |
81 ms |
5712 KB |
Output is correct |
54 |
Correct |
77 ms |
5972 KB |
Output is correct |
55 |
Correct |
82 ms |
5712 KB |
Output is correct |
56 |
Correct |
52 ms |
4432 KB |
Output is correct |
57 |
Correct |
35 ms |
1620 KB |
Output is correct |
58 |
Correct |
66 ms |
4564 KB |
Output is correct |
59 |
Correct |
52 ms |
4428 KB |
Output is correct |
60 |
Correct |
29 ms |
1628 KB |
Output is correct |
61 |
Correct |
50 ms |
4676 KB |
Output is correct |
62 |
Correct |
85 ms |
5712 KB |
Output is correct |
63 |
Correct |
86 ms |
5712 KB |
Output is correct |
64 |
Correct |
114 ms |
5832 KB |
Output is correct |
65 |
Correct |
87 ms |
5848 KB |
Output is correct |
66 |
Correct |
86 ms |
5840 KB |
Output is correct |
67 |
Correct |
86 ms |
5944 KB |
Output is correct |
68 |
Correct |
86 ms |
5716 KB |
Output is correct |
69 |
Correct |
92 ms |
5712 KB |
Output is correct |
70 |
Correct |
85 ms |
5716 KB |
Output is correct |
71 |
Correct |
87 ms |
5852 KB |
Output is correct |
72 |
Correct |
84 ms |
5716 KB |
Output is correct |
73 |
Correct |
86 ms |
5848 KB |
Output is correct |