Submission #1011634

#TimeUsernameProblemLanguageResultExecution timeMemory
1011634phongExhibition (JOI19_ho_t2)C++17
100 / 100
46 ms4728 KiB
#include<bits/stdc++.h>

#define ll long long
const int nmax = 1e5 + 5, N = 3e5 + 5;
const ll oo = 1e18;
const int lg = 18, M = 4e3;
const int base = 2e5, mod = 1e9 + 7;
#define pii pair<int, int>
#define fi first
#define se second
#define endl "\n"
#define debug(a, n) for(int i = 1; i <= n; ++i) cout << a[i] << ' ';cout << endl
using namespace std;


int n, m;
pii a[nmax];
int c[nmax];

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
//        freopen("code.inp", "r", stdin);
//        freopen("code.out", "w", stdout);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> a[i].fi >> a[i].se;
    for(int i = 1; i <= m; ++i) cin >> c[i];
    sort(a + 1, a + 1 + n, [](pii a, pii b){
            if(a.se == b.se) return a.fi > b.fi;
            return a.se > b.se;
         });
    sort(c + 1, c + 1 + m, [](int a, int b){
            return a > b;
         });
    int pos = 1, cnt = 0;
    for(int i = 1; i <= m; ++i){
        while(pos <= n && a[pos].fi > c[i]){
            ++pos;
        }
        if(pos > n) break;
        cnt++;
        ++pos;
    }
    cout << cnt;


}
/*
si <= ci
ci <= ci + 1
vi <= vi + 1
1 2 3 4 5 6
*/

Compilation message (stderr)

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