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;
using vll = vector <ll>;
int main () {
cin.tie(nullptr) -> sync_with_stdio(false);
ll n, m;
cin >> n >> m;
vector <pair <ll, ll> > ve(n);
for (auto &[v, s] : ve) cin >> s >> v;
vll vfr(m);
for (ll &i : vfr) cin >> i;
sort(vfr.rbegin(), vfr.rend());
sort(ve.begin(), ve.end()); // a.v>b.v, if equal, a.s>b.s
ll ans = 0;
ll curVal = ll(1E18)+16;
for (ll fr : vfr) {
while (ve.size() && (ve.back().second > fr || ve.back().first > curVal)) ve.pop_back();
if (!ve.size()) break;
ans++;
curVal = ve.back().first;
ve.pop_back();
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |