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;
using ll = long long;
struct pic {
int sz, val;
};
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<pic> p;
vector<int> f;
for (int i = 0; i < n; i++) {
int sz, val;
cin >> sz >> val;
p.push_back({.sz = sz, .val = val});
}
for (int i = 0; i < m; i++) {
int c;
cin >> c;
f.push_back(c);
}
sort(p.begin(), p.end(), [](pic &u, pic &v) {
if (u.val < v.val) return true;
else if (u.val > v.val) return false;
else return u.sz < v.sz;
});
sort(f.begin(), f.end());
int ans = 0;
int pnt = m - 1;
for (int i = n - 1; i >= 0; i--) {
if (pnt == -1) continue;
if (p[i].sz <= f[pnt]) {
++ans;
--pnt;
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |