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>
#define ll long long
#define f first
#define sc second
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l,idx,B[500005],le,ri,mid,ans;
pair <ll , ll> A[500005];
bool go(ll x) {
//cout<<x<<" ";
idx=m-x+1;
for(ll i=1;i<=n;i++) {
if(A[i].sc<=B[idx]) idx++;
if(idx==m+1) return 1;
}
return 0;
}
int main() {
cin>>n>>m;
for(ll i=1;i<=n;i++) {
cin>>A[i].sc>>A[i].f;
}
for(ll i=1;i<=m;i++) {
cin>>B[i];
}
sort(A+1,A+1+n);
sort(B+1,B+1+m);
le=1; ri=min(n,m);
while(le<=ri) {
mid=(le+ri)/2;
if(go(mid)==1) { le=mid+1; ans=mid; }
else ri=mid-1;
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |