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>
#define ll long long
#define ar array
#define db double
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rint(l, r) uniform_int_distribution<int>(l, r)(rng)
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
void test_case() {
int n, m;
cin >> n >> m;
vector<int> X, Y;
vector<ar<int, 2>> a(n);
for (auto &x : a) cin >> x[0] >> x[1];
vector<int> s(m);
for (int &x : s) cin >> x;
sort(all(a), [&](auto &A, auto &B) { return A[1] != B[1] ? A[1] < B[1] : A[0] < B[0]; });
sort(all(s));
int lst = 0;
for (int i = n-1; i >= 0; i--) {
auto [x, y] = a[i];
int use = s[m - lst - 1];
if (use >= x) lst++;
if (lst == m) {
cout << m << '\n'; return;
}
}
cout << lst << '\n';
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
while (t--) test_case();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |