Submission #397453

#TimeUsernameProblemLanguageResultExecution timeMemory
397453giorgikobExhibition (JOI19_ho_t2)C++14
100 / 100
64 ms4424 KiB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int N = 1e6+50, mod = 1e9+7, K = 31;

int n,m;
int x,y;
int A[N];
int dp[N];
int res;
pair<int,int>P[N];
set<pair<int,int>>s;

inline bool check(int x){

    int a = m-x+1;
    for(int i = 1; i <= n; i++){
        if(P[i].ss <= A[a]){
            a++;
        }
        if(a == m+1) return true;
    }

    return false;
}

inline void test_case(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> x >> y;
        P[i] = {y,x};
    }

    sort(P+1,P+1+n);

    for(int i = 1; i <= m; i++){
        cin >> A[i];
    }

    sort(A+1,A+1+m);

    int l = 1, r = min(n,m);

    int res = 0;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            res = mid;
            l = mid+1;
        } else {
            r = mid-1;
        }
    }

    cout << res << endl;
}
 main(){
    ios::sync_with_stdio(0);

    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; i++){
        test_case();
    }
}

Compilation message (stderr)

joi2019_ho_t2.cpp:61:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   61 |  main(){
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...