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 <algorithm>
using namespace std;
#define st first
#define nd second
const int N = 1e5+5;
int n, m;
pair<int,int> pic[N];
int frame[N];
bool check(int val)
{
int pos = val;
for (int i = 0; i < n; i++)
{
if (pic[i].nd <= frame[pos])
{
pos++;
}
}
//cout << pos << endl;
if (pos == m)
return 1;
return 0;
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> pic[i].nd >> pic[i].st;
}
for (int i = 0; i < m; i++)
{
cin >> frame[i];
}
sort(pic,pic+n);
sort(frame,frame+m);
int l = 0, r = m, mid, ans = 0;
while(l != r)
{
mid = (l+r)/2;
//cout << l << ' ' << mid << ' ' << r << endl;
if (check(m-mid))
{
ans = max(ans,mid);
l = mid+1;
}
else
r = mid;
if (l == r)
{
if (check(m-l))
ans = max(ans,l);
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |