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;
#define int long long
vector<pair<int, int>> v;
vector<int> frames;
int n, m;
bool isOkay(int k) {
int start = 0;
for (int i = k; i < m; i++) {
while (start < n && v[start].second > frames[i]) {
start++;
}
if (start == n) {
return false;
} else {
start++;
}
}
return true;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
v.push_back({b, a});
}
for (int i = 0; i < m; i++) {
int c;
cin >> c;
frames.push_back(c);
}
sort(v.begin(), v.end());
sort(frames.begin(), frames.end());
int low = -1;
int high = m;
while (high - low > 1) {
int mid = (high + low) / 2;
if (isOkay(mid)) {
high = mid;
} else {
low = mid;
}
}
cout << m - high;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |