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 <fstream>
#include <algorithm>
using namespace std;
const int nmax=100005;
pair<int,int> v[nmax];
int a[nmax];
int n,m,i;
bool check(int poz)
{
poz=m-poz+1;
for(i=1;i<=n;i++)
if(poz<=m&&v[i].second<=a[poz])
poz++;
return (poz>m);
}
int main()
{
//freopen("data.in","r",stdin);
ios_base::sync_with_stdio(false);
cin>>n>>m;
for(i=1;i<=n;i++)
{
cin>>v[i].second>>v[i].first;
}
sort(v+1,v+n+1);
for(i=1;i<=m;i++)
{
cin>>a[i];
}
sort(a+1,a+m+1);
int ans=0;
for(int p=17;p>=0;p--)
if(ans+(1<<p)<=m&&check(ans+(1<<p)))
ans+=(1<<p);
cout<<ans;
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... |