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 <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl "\n"
llo mod=1000000007;
llo n,m;
pair<llo,llo> it[100002];
llo aa[100001];
llo check(llo mid){
llo ind=m-1;
llo tot=0;
for(llo i=n-1;i>=0;i--){
if(it[i].b<=aa[ind]){
tot+=1;
ind-=1;
}
}
return tot>=mid;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m;
for(llo i=0;i<n;i++){
cin>>it[i].b>>it[i].a;
}
for(llo i=0;i<m;i++){
cin>>aa[i];
}
sort(it,it+n);
sort(aa,aa+m);
llo low=0;
llo high=m;
while(low<high-1){
llo mid=(low+high)/2;
if(check(mid)){
low=mid;
}
else{
high=mid-1;
}
}
llo ans;
for(llo i=high;i>=low;i--){
if(check(i)){
ans=i;
break;
}
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |