#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 2e5 + 100;
int n, m;
vector<pair<int,int>> v1;
vector<int> v2;
bool check(int x) {
vector<pair<int,int>> vv(v1.begin(), v1.end());
reverse(vv.begin(), vv.end());
vector<int> Q;
for (int i = m - x; i < m; i++)
Q.push_back(v2[i]);
reverse(Q.begin(), Q.end());
while (vv.size() && Q.size()) {
int x = vv.back().f;
vv.pop_back();
if (Q.back() >= x)
Q.pop_back();
}
return Q.empty();
}
int main() {
fast;
cin >> n >> m;
v1 = vector<pair<int,int>>(n);
v2 = vector<int>(m);
for (int i = 0; i < n; i++)
cin >> v1[i].f >> v1[i].s;
for (int i = 0; i < m; i++)
cin >> v2[i];
sort(v1.begin(), v1.end(), [&](pair<int,int> A, pair<int,int> B) {
return A.s < B.s;
});
sort(v2.begin(), v2.end());
int L = 1, R = min(n, m);
int ans = 0;
while (R >= L) {
int mid = L + (R - L) / 2;
if (check(mid)) {
ans = mid;
L = mid + 1;
} else
R = mid - 1;
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |