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;
const int N = 1e5+4;
int fr[N];
int n, m;
struct pic
{
int sz, v;
} a[N];
bool cmp(pic a, pic b)
{
if(a.v == b.v)
return a.sz > b.sz;
return a.v > b.v;
}
bool ck(int len)
{
int j = m;
for(int i=1;i<=n;i++)
{
// cout<<a[i].sz<<' '<<fr[j]<<'\n';
if(a[i].sz <= fr[j])
{
j--;
if(j == m-len)
return true;
}
}
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i].sz>>a[i].v;
}
for(int i=1;i<=m;i++)
{
cin>>fr[i];
}
// cout<<fr[1]<<' '<<fr[2];
sort(a+1,a+1+n,cmp);
sort(fr+1,fr+1+m);
// cout<<ck(2);
int L = 0, R = min(n, m), res = 0;
while(L <= R)
{
int mid = (L+R)/2;
// cout<<mid<<'\n';
// cout<<L<<' '<<R<<' '<<mid<<'\n';
if(ck(mid) == true)
{
res = max(res ,mid);
L = mid+1;
}
else
R = mid-1;
}
cout<<res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |