Submission #529944

# Submission time Handle Problem Language Result Execution time Memory
529944 2022-02-24T06:15:13 Z scottchou Exhibition (JOI19_ho_t2) C++17
100 / 100
298 ms 5376 KB
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int const N = 1e5 + 5;
typedef pair<int, int> pii;
pii pic[N];
int c[N], n, m;
bool check(int x){
    int idx = 0;
    priority_queue<int, vector<int>, greater<int> > pq;
    int last = 0;
    for(int i = x - 1; i >= 0; i--){
        while(idx < n && pic[idx].first <= c[i]){
            if(pic[idx].second >= last)
                pq.push(pic[idx].second);
            idx++;
        }
        if(pq.empty()){
           return 0;
        }
        last = pq.top();
        pq.pop();
    }
    return 1;
}
int main(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> pic[i].first >> pic[i].second;
    }
    for(int i = 0; i < m; i++){
        cin >> c[i];
    }
    sort(pic, pic + n);
    sort(c, c + m);
    reverse(c, c + m);
    int l = 0, r = n;
    while(l < r){
        int mid = l + r + 1 >> 1;
        if(check(mid)){
            l = mid;
        }else{
            r = mid - 1;
        }
    }
    cout << l << '\n';
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:40:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |         int mid = l + r + 1 >> 1;
      |                   ~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 1 ms 312 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 0 ms 304 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 1 ms 312 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 2 ms 336 KB Output is correct
38 Correct 172 ms 4752 KB Output is correct
39 Correct 162 ms 4696 KB Output is correct
40 Correct 216 ms 4724 KB Output is correct
41 Correct 201 ms 4724 KB Output is correct
42 Correct 120 ms 4292 KB Output is correct
43 Correct 121 ms 4292 KB Output is correct
44 Correct 175 ms 4772 KB Output is correct
45 Correct 298 ms 4904 KB Output is correct
46 Correct 247 ms 4872 KB Output is correct
47 Correct 179 ms 4452 KB Output is correct
48 Correct 160 ms 4336 KB Output is correct
49 Correct 215 ms 3952 KB Output is correct
50 Correct 188 ms 4032 KB Output is correct
51 Correct 120 ms 4232 KB Output is correct
52 Correct 121 ms 4356 KB Output is correct
53 Correct 117 ms 4200 KB Output is correct
54 Correct 228 ms 5376 KB Output is correct
55 Correct 151 ms 4688 KB Output is correct
56 Correct 84 ms 3268 KB Output is correct
57 Correct 43 ms 1604 KB Output is correct
58 Correct 80 ms 3884 KB Output is correct
59 Correct 87 ms 3888 KB Output is correct
60 Correct 44 ms 1560 KB Output is correct
61 Correct 113 ms 2812 KB Output is correct
62 Correct 238 ms 4740 KB Output is correct
63 Correct 237 ms 4752 KB Output is correct
64 Correct 241 ms 4732 KB Output is correct
65 Correct 259 ms 5124 KB Output is correct
66 Correct 233 ms 4732 KB Output is correct
67 Correct 240 ms 4744 KB Output is correct
68 Correct 234 ms 4852 KB Output is correct
69 Correct 239 ms 4744 KB Output is correct
70 Correct 237 ms 4972 KB Output is correct
71 Correct 230 ms 4736 KB Output is correct
72 Correct 204 ms 4768 KB Output is correct
73 Correct 224 ms 4876 KB Output is correct