#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=2e5+5,mod=1e9+7;
int t,c[N],ans,n,m;
pair<int,int>p[N];
bool check(int ind){
int cnt = 0, l=1;
for(int i=ind;i>=1;i--){
while(l<=n && p[l].s > c[i]) l++;
if(l<=n && p[l].s<=c[i]) cnt++,l++;
}
if(cnt==ind) return 1;
return 0;
}
string s;
main(){
// t=1;
cin >> n>>m;
for(int i=1;i<=n;i++){
cin>>p[i].s >> p[i].f;
}
sort(p+1,p+n+1);
for(int i=1;i<=m;i++){
cin>>c[i];
}
sort(c+1,c+1+m);
reverse(c+1,c+m+1);
int l=1,r=min(n,m);
while(l<=r){
int mid=(l+r)/2;
if(check(mid)) {
ans=mid;
l=mid+1;
}
else r=mid-1;
}
cout<<ans;
}
Compilation message
joi2019_ho_t2.cpp:19:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
19 | main(){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
2 ms |
316 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
316 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
2 ms |
356 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
2 ms |
320 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
2 ms |
332 KB |
Output is correct |
32 |
Correct |
2 ms |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
316 KB |
Output is correct |
34 |
Correct |
2 ms |
332 KB |
Output is correct |
35 |
Correct |
1 ms |
332 KB |
Output is correct |
36 |
Correct |
2 ms |
320 KB |
Output is correct |
37 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
2 ms |
316 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
316 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
2 ms |
356 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
2 ms |
320 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
2 ms |
332 KB |
Output is correct |
32 |
Correct |
2 ms |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
316 KB |
Output is correct |
34 |
Correct |
2 ms |
332 KB |
Output is correct |
35 |
Correct |
1 ms |
332 KB |
Output is correct |
36 |
Correct |
2 ms |
320 KB |
Output is correct |
37 |
Correct |
2 ms |
332 KB |
Output is correct |
38 |
Correct |
145 ms |
5588 KB |
Output is correct |
39 |
Correct |
144 ms |
5428 KB |
Output is correct |
40 |
Correct |
139 ms |
5536 KB |
Output is correct |
41 |
Correct |
144 ms |
5500 KB |
Output is correct |
42 |
Correct |
142 ms |
5536 KB |
Output is correct |
43 |
Correct |
145 ms |
5460 KB |
Output is correct |
44 |
Correct |
145 ms |
5508 KB |
Output is correct |
45 |
Correct |
143 ms |
5444 KB |
Output is correct |
46 |
Correct |
141 ms |
5424 KB |
Output is correct |
47 |
Correct |
127 ms |
4896 KB |
Output is correct |
48 |
Correct |
127 ms |
4912 KB |
Output is correct |
49 |
Correct |
117 ms |
4384 KB |
Output is correct |
50 |
Correct |
115 ms |
4468 KB |
Output is correct |
51 |
Correct |
144 ms |
5540 KB |
Output is correct |
52 |
Correct |
143 ms |
5532 KB |
Output is correct |
53 |
Correct |
143 ms |
5576 KB |
Output is correct |
54 |
Correct |
141 ms |
5500 KB |
Output is correct |
55 |
Correct |
145 ms |
5572 KB |
Output is correct |
56 |
Correct |
94 ms |
3780 KB |
Output is correct |
57 |
Correct |
49 ms |
1960 KB |
Output is correct |
58 |
Correct |
91 ms |
3736 KB |
Output is correct |
59 |
Correct |
92 ms |
3780 KB |
Output is correct |
60 |
Correct |
50 ms |
1956 KB |
Output is correct |
61 |
Correct |
82 ms |
3248 KB |
Output is correct |
62 |
Correct |
147 ms |
5444 KB |
Output is correct |
63 |
Correct |
153 ms |
5436 KB |
Output is correct |
64 |
Correct |
151 ms |
5428 KB |
Output is correct |
65 |
Correct |
147 ms |
5468 KB |
Output is correct |
66 |
Correct |
148 ms |
5532 KB |
Output is correct |
67 |
Correct |
164 ms |
5448 KB |
Output is correct |
68 |
Correct |
147 ms |
5444 KB |
Output is correct |
69 |
Correct |
151 ms |
5448 KB |
Output is correct |
70 |
Correct |
149 ms |
5428 KB |
Output is correct |
71 |
Correct |
147 ms |
5444 KB |
Output is correct |
72 |
Correct |
147 ms |
5552 KB |
Output is correct |
73 |
Correct |
148 ms |
5488 KB |
Output is correct |