This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |