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<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7
using namespace std;
ll n,m,cost[N];
pi ar[N];
bool check(ll k)
{
ll frame = m-k;
rep(i,0,n)
{
if(ar[i].second <= cost[frame])
frame++;
if(frame == m)
return true;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> m;
rep(i,0,n)
{
cin >> ar[i].second >> ar[i].first;
}
rep(i,0,m)
{
cin >> cost[i];
}
sort(ar,ar+n);
sort(cost,cost+m);
ll low = 0;
ll high = min(n,m);
ll res = 0;
while(low <= high)
{
ll mid= (low+high)/2;
if(check(mid))
{
low = mid+1;
res = mid;
}
else
{
high= mid-1;
}
}
cout << res;
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... |