#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
int N, M;
int main() {
cin >> N >> M;
vector<pair<int, int>> pictures(N);
vector<int> frames(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 curMin = -1;
for (int i = 0; i < N; i++) {
if (pictures[i].s < curMin) {
for (int j = i; j >= 0; j--) {
if (pictures[j].s > curMin) {
pictures[j].f = -1;
continue;
}
break;
}
}
curMin = pictures[i].s;
}
int ans = 0;
int i = 0;
int j = 0;
while (i < N && j < M) {
if (pictures[i].f == -1) {
i++;
continue;
}
bool flag = false;
while (frames[j] < pictures[i].s) {
j++;
if (j == M) {
flag = true;
break;
}
}
if (flag) break;
ans++;
i++;
j++;
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |