#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";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |