# include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
using namespace std;
const int N=3e5+5;
long long ff,b[N],ri,le,mid,n,m,ans;
pair <long long , long long> a[N];
int check (int mid) {
int ri=m;
for (int i=mid; i>=1; i--) {
ff=0;
while (ri>0) {
if (b[ri]>=a[i].s) {
// cout<<b[ri]<<" "<<a[i].s<<endl;
ri--;
ff=1;
break;
}
ri--;
}
if (!ff) break;
}
if (!ff) return 0;
else return 1;
}
int main() {
cin>>n>>m;
for (int i=1; i<=n; i++) {
cin>>a[i].s>>a[i].f;
}
sort(a+1, a+n+1);
for (int i=1; i<=m; i++) {
cin>>b[i];
}
sort(b+1, b+m+1);
le=1;
ri=n;
while (le<=ri) {
int mid=(le+ri)/2;
// cout<<mid<<" "<<le<<" "<<ri<<endl;
if (check(mid)) {
le=mid+1;
ans=mid;
} else {
ri=mid-1;
}
}
cout<<ans<<endl;
}
# |
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 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |