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
#define pb push_back
#define ld long double
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m;
cin >> n >> m;
vector<pair<int, int>> K(n);
for (int i = 0; i < n; i++) cin >> K[i].second >> K[i].first;
vector<int> R(m);
for (int i = 0; i < m; i++) cin >> R[i];
int l = -1, r = min(n, m);
sort(K.begin(), K.end());
sort(R.begin(), R.end());
while (r - l > 1) {
int mid = (l + r) / 2;
int uk = m - mid - 1;
bool f = false;
for (auto p : K) {
if (p.second <= R[uk]) {
uk++;
if (uk == m) {
f = true;
break;
}
}
}
if (f) {
l = mid;
} else {
r = mid;
}
}
cout << l + 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |