제출 #963358

#제출 시각아이디문제언어결과실행 시간메모리
963358efishelExhibition (JOI19_ho_t2)C++17
100 / 100
47 ms5752 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...