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;
using nagai = long long;
#define sz(x) int((x).size())
const int N=100100;
int s[N],v[N],c[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin>>n>>m;
vector<int>ord1(n);
for(int i=0;i<n;++i)
cin>>s[i]>>v[i];
for(int i=0;i<m;++i)cin>>c[i];
iota(ord1.begin(),ord1.end(),0);
sort(ord1.begin(),ord1.end(),[&](int a,int b){
if(v[a]!=v[b])
return v[a]<v[b];
return s[a]<s[b];
});
sort(c,c+m);
int ans=0;
int cur=n-1;
for(int i=m-1;i>=0;--i){
while(cur>=0&&s[ord1[cur]]>c[i])--cur;
if(cur>=0)++ans,--cur;
}
cout<<ans<<'\n';
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... |