Submission #1034149

#TimeUsernameProblemLanguageResultExecution timeMemory
1034149vjudge1Exhibition (JOI19_ho_t2)C++17
100 / 100
45 ms5712 KiB
#include<bits/stdc++.h>
#define ll long long
#define ii pair<long long, long long>
using namespace std;

const int MAXN = 1e5 + 5;

ll n,m,res;
ii p[MAXN];
ll c[MAXN];

bool cmp(ii a, ii b){
    if(a.first > b.first) return true;
    else if(a.first == b.first) return a.second > b.second;
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>m;
    for(int i = 1;i<=n;i++){
        cin>>p[i].second>>p[i].first;
    }
    for(int i = 1;i<=m;i++) cin>>c[i];
    sort(p+1,p+n+1,cmp);
    sort(c+1,c+m+1);

    int j = 1;
    for(int i = m;i>=1;i--){
        while(j <= n && p[j].second > c[i]){
            j++;
        }
        if(j == n+1){
            break;
        }
        else{
            res++;
            j++;
        }
    }
    cout<<res;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...