Submission #1297444

#TimeUsernameProblemLanguageResultExecution timeMemory
1297444hssaan_arifExhibition (JOI19_ho_t2)C++20
100 / 100
37 ms3820 KiB
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define pb push_back
#define int long long
#define fi first
#define se second

const int N = 3e5 + 5, M = 1e9 + 7, LG = 20;

int n , A[N] , q , s , v;

void solve(){
    cin >> n >> q;
    vector<pair<int,int>> d;
    for (int i=1 ; i<=n ; i++){
        cin >> s >> v;
        d.pb({v,s});
    }
    sort(d.begin() , d.end());
    vector<int> f;
    for (int i=1 ; i<=q ; i++){
        cin >> s;
        f.pb(s);
    }
    sort(f.rbegin() , f.rend());
    int ans = 0;
    for (int i=0 ; i<q ; i++){
        int u = f[i];
        while(d.size() && d.back().se > u){
            d.pop_back();
        }
        if (!d.size()) break;
        ans++;
        d.pop_back();
    }
    cout << ans << endl;
}

signed main(){
    // freopen("" , "r" , stdin);
    // freopen("" , "w" , stdout);
    // cout << setprecision(30);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int ts = 1;
    // cin >> ts;
    while(ts--){
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...