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 f first
#define s second
int N, M;
vector<pair<int, int>> pictures;
vector<int> frames;
bool check(int x) {
int high = N-1;
int low = 0;
while (low < high) {
int mid = (low+high)/2;
int j = mid;
int k = M-1;
int ans = 0;
while ((j >= 0) && (k >= 0)) {
bool flag = false;
while (pictures[j].s > frames[k]) {
j--;
if (j < 0) {
flag = true;
break;
}
}
if (flag) break;
ans++;
j--;
k--;
}
if (ans >= x) {
return true;
}
else {
high = mid-1;
}
}
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> M;
pictures.resize(N);
frames.resize(M);
for (int i = 0; i < N; i++) {
cin >> pictures[i].s >> pictures[i].f;
}
for (int i = 0; i < M; i++) {
cin >> frames[i];
}
sort(pictures.begin(), pictures.end());
sort(frames.begin(), frames.end());
int high = min(N, M);
int low = 0;
while (low < high) {
int mid = (low+high+1)/2;
if (check(mid)) {
low = mid;
}
else {
high = mid-1;
}
}
cout << low << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |