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 fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
using namespace std;
struct lena{
int c,w;
}a[6000001];
bool cmp(const lena &p, const lena &q){
return ((p.c>q.c)||(p.c==q.c&&p.w>q.w));
}
int b[6000001];
int main()
{
fastio
//freopen(".INP","r",stdin);
//freopen(".OUT","w",stdout);
int n,m;
cin>>n>>m;
for (int i=1;i<=n;i++){
cin>>a[i].w>>a[i].c;
}
sort(a+1,a+1+n,cmp);
for (int i=1;i<=m;i++){
cin>>b[i];
}
sort(b+1,b+1+m,greater<int>());
int j=1;
int cnt=0;
for (int i=1;i<=n;i++){
if (j==m+1)break;
if (b[j]>=a[i].w){
cnt++;
j++;
}
//else j++;
}
cout<<cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |