Submission #746523

#TimeUsernameProblemLanguageResultExecution timeMemory
746523ducanh1234Exhibition (JOI19_ho_t2)C++14
100 / 100
59 ms5592 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define dbg(...) cerr << "LINE(" << __LINE__ << ") : [" <<  #__VA_ARGS__ << "] = [", debug(__VA_ARGS__), cerr << "]\n";  
#define rep(i, b) for(int i = 0; i < (int)b; i++)
#define FOR(i, a, b) for(int i = (int)(a); i <= (int)(b); i++)       
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back 
#define vt vector
#define in(type, ...) type __VA_ARGS__; read(__VA_ARGS__);
template<class T> void read(T& t){ cin >> t; }
template<class T, class... H> void read(T& t, H&...h){ read(t); read(h...); }
template<class T> void read(vector<T>& t){ FOR(i, 0, sz(t) - 1) read(t[i]); }
template<class T> void write(const T t){ cout << t << ' ';}
template<class T> void print(const T t){ cout << t << '\n';}
template<class T,class...H> void print(const T& t, const H&...h){ cout << t; cout << " "; print(h...); }
template<class T> void debug(const T t) { cerr << t; } 
template<class T,class...H> void debug(const T& t, const H&...h){ 
    cerr << t; 
    if(sizeof...(h)) cerr << ", ";
    debug(h...); 
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m; read(n, m);
    vt<pair<int, int>> a(n);
    vt<int> b(m);
    FOR(i, 0, n - 1) read(a[i].second, a[i].first);
    sort(all(a), [&](const pair<int, int>& x, const pair<int, int>& y){
        return x.first < y.first || (x.first == y.first && x.second < y.second);
    });
    read(b);
    sort(all(b));
    int cnt = 0;
    for(int i = n - 1; i >= 0; i--){
        if(b[m - cnt - 1] >= a[i].second && m - cnt >= 1) cnt++;
    }
    print(cnt);
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...