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;
struct pos
{
int val, s;
bool operator<(pos b)
{
if(val != b.val)
return val<b.val;
return s < b.s;
}
};
int n,m;
pos v[100005];
int s[100005];
int st, dr, mij, last;
bool ok(int k)
{
int j=m-k+1;
for(int i=1;i<=n;i++)
{
if(j<=m && v[i].s <= s[j])
j++;
}
return (j == m+1);
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>v[i].s>>v[i].val;
sort(v+1, v+n+1);
for(int i=1;i<=m;i++)
cin>>s[i];
sort(s+1, s+m+1);
st=1, dr=n;
while(st <= dr)
{
mij = (st+dr)/2;
if(ok(mij))
{
last=mij;
st=mij+1;
}
else
dr=mij-1;
}
cout<<last;
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... |