Submission #1173578

#TimeUsernameProblemLanguageResultExecution timeMemory
1173578nguyenkhangninh99Exhibition (JOI19_ho_t2)C++17
100 / 100
32 ms2632 KiB

#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
const int maxn = 1e5 + 5;

struct l0301{
    int s, v;
} buctranh[maxn];

bool cmp(l0301 x, l0301 y){
    if(x.v == y.v) return x.s > y.s;
    return (x.v > y.v);
    
}
int c[maxn];

void solve(){
    int n, m; cin >> n >> m;

    for(int i = 1; i <= n; i++) cin >> buctranh[i].s >> buctranh[i].v;
    for(int i = 1; i <= m; i++) cin >> c[i];

    sort(buctranh + 1, buctranh + n + 1, cmp);
    sort(c + 1, c + m + 1, greater<int>());

    int i = 1, j = 1, ans = 0;
    while(i <= n && j <= m){
        if(c[j] >= buctranh[i].s) ans++, j++;
        i++;
    }

    cout << ans;
}
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
 
    solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...