Submission #971128

# Submission time Handle Problem Language Result Execution time Memory
971128 2024-04-28T03:24:31 Z Roumak77 Exhibition (JOI19_ho_t2) C++17
100 / 100
47 ms 5804 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;

using ll = long long;
#define v first
#define s second

bool check(ll mid, vector<pair<ll, ll>> &a, ll n, ll m, vector<ll> &c){
    //cout << mid << endl;
    ll idx = 0;
    for(ll i = mid; i < m; i++){
        if(idx >= n){
            return false;
        }
        while(a[idx].s > c[i]){
            idx++;
            if(idx == n){
                return false;
            }
        }
        idx++;
    }
    return true;

}

void solve(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> a(n, pair<ll, ll>{0, 0});
    vector<ll> c(m, 0);
    for(ll i = 0; i < n; i++){
        cin >> a[i].s >> a[i].v;
    }
    for(ll i = 0; i < m; i++){
        cin >> c[i];
    }

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    ll l = -1;
    ll r = m;
    while(l + 1 < r){
        ll mid = (l + r)/2;

        if(check(mid, a, n, m, c)){
            r = mid;
        }else{
            l = mid;
        }

    }

    cout << m - r;




}


int main(){

    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);

    ll t = 1;

    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 520 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 520 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 40 ms 5488 KB Output is correct
39 Correct 44 ms 5804 KB Output is correct
40 Correct 35 ms 5520 KB Output is correct
41 Correct 42 ms 5620 KB Output is correct
42 Correct 37 ms 5468 KB Output is correct
43 Correct 37 ms 5456 KB Output is correct
44 Correct 39 ms 5468 KB Output is correct
45 Correct 41 ms 5468 KB Output is correct
46 Correct 39 ms 5456 KB Output is correct
47 Correct 39 ms 4956 KB Output is correct
48 Correct 35 ms 4948 KB Output is correct
49 Correct 32 ms 4444 KB Output is correct
50 Correct 32 ms 4444 KB Output is correct
51 Correct 37 ms 5456 KB Output is correct
52 Correct 39 ms 5484 KB Output is correct
53 Correct 37 ms 5456 KB Output is correct
54 Correct 35 ms 5616 KB Output is correct
55 Correct 40 ms 5456 KB Output is correct
56 Correct 22 ms 3928 KB Output is correct
57 Correct 14 ms 2140 KB Output is correct
58 Correct 22 ms 3932 KB Output is correct
59 Correct 23 ms 3928 KB Output is correct
60 Correct 14 ms 2140 KB Output is correct
61 Correct 24 ms 3192 KB Output is correct
62 Correct 44 ms 5468 KB Output is correct
63 Correct 47 ms 5464 KB Output is correct
64 Correct 44 ms 5468 KB Output is correct
65 Correct 44 ms 5464 KB Output is correct
66 Correct 44 ms 5456 KB Output is correct
67 Correct 43 ms 5464 KB Output is correct
68 Correct 44 ms 5624 KB Output is correct
69 Correct 45 ms 5456 KB Output is correct
70 Correct 42 ms 5700 KB Output is correct
71 Correct 47 ms 5716 KB Output is correct
72 Correct 40 ms 5492 KB Output is correct
73 Correct 41 ms 5704 KB Output is correct