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 fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
pair<int,int> t[N];
int t2[N];
int n,m;
int bs(int x){
int pocz=1,kon=m,sr,res=-1;
while(pocz<=kon){
sr=(pocz+kon)>>1;
if(t2[sr]>=x) res=sr,kon=sr-1;
else pocz=sr+1;
}
return res;
}
void solve(){
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>t[i].se>>t[i].fi;
sort(t+1,t+1+n);
for(int i=1;i<=m;i++) cin>>t2[i];
sort(t2+1,t2+1+m);
int maxi=0;
for(int i=n;i>=1;i--){
int g=bs(t[i].se);
if(g==-1) continue;
g=m-g+1;
g=min(g,maxi+1);
maxi=max(maxi,g);
}
cout<<maxi<<"\n";
}
int main(){
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |