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>
#define v first
#define s second
using namespace std;
int n, m, b[100010], l, r, mid;
pair<int,int> a[100010];
bool check() {
int pos = 1;
for (int i = mid; i <= m; i++) {
while ((pos <= n) && (a[pos].s > b[i])) pos++;
if (pos > n) return 0;
pos++;
}
return 1;
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i].s >> a[i].v;
for (int i = 1; i <= m; i++) cin >> b[i];
sort(a+1,a+n+1);
sort(b+1,b+m+1);
l = 1; r = m;
while (l <= r) {
mid = (l+r)/2;
if (check()) r = mid-1;
else l = mid+1;
}
cout << m-r << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |