# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1005515 | 2024-06-22T14:27:48 Z | khanhtb | 드문 곤충 (IOI22_insects) | C++17 | 45 ms | 1180 KB |
#include<bits/stdc++.h> #include "insects.h" #define ll int #define ull unsigned long long #define ld double #define pb push_back #define pf push_front #define vi vector<ll> #define vii vector<vi> #define pll pair<ll,ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define fi first #define se second using namespace std; const ll mod = 1e9+7; const ll inf = 1e18; const ll base = 31; const ll blocksz = 320; const ll N = 1e5+8; multiset<int> in_machine; map<int,multiset<int>> max_k; vector<int> reset; int n,d; void add(ll i){ move_inside(i); in_machine.insert(i); } void del(ll i){ move_outside(i); in_machine.erase(in_machine.find(i)); } bool check(int m){ reset.clear(); auto mk = *max_k.lower_bound(m); for(int p:mk.se){ if(in_machine.find(p) != in_machine.end()) continue; if((int)in_machine.size() >= d*m) return 1; add(p); if(press_button() > m) del(p); else reset.pb(p); } max_k[m] = in_machine; if((int)in_machine.size() >= d*m) return 1; return 0; } int min_cardinality(int n){ for(int i = 0; i < n; i++){ add(i); if(press_button() > 1) del(i); } d = (int)in_machine.size(); max_k[1] = in_machine; for(int i = 0; i < n; i++) max_k[n].insert(i); int ans = 1; int l = 2, r = n/d; while(l <= r){ int m = l+r>>1; if(check(m)){ ans = m; l = m+1; } else{ r = m-1; for(int i:reset) del(i); } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 3 ms | 452 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 3 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 2 ms | 344 KB | Output is correct |
13 | Correct | 2 ms | 344 KB | Output is correct |
14 | Correct | 2 ms | 344 KB | Output is correct |
15 | Correct | 4 ms | 460 KB | Output is correct |
16 | Correct | 3 ms | 344 KB | Output is correct |
17 | Correct | 5 ms | 344 KB | Output is correct |
18 | Correct | 2 ms | 344 KB | Output is correct |
19 | Correct | 2 ms | 344 KB | Output is correct |
20 | Correct | 2 ms | 344 KB | Output is correct |
21 | Correct | 2 ms | 344 KB | Output is correct |
22 | Correct | 1 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 3 ms | 452 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 3 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 2 ms | 344 KB | Output is correct |
13 | Correct | 2 ms | 344 KB | Output is correct |
14 | Correct | 2 ms | 344 KB | Output is correct |
15 | Correct | 4 ms | 460 KB | Output is correct |
16 | Correct | 3 ms | 344 KB | Output is correct |
17 | Correct | 5 ms | 344 KB | Output is correct |
18 | Correct | 2 ms | 344 KB | Output is correct |
19 | Correct | 2 ms | 344 KB | Output is correct |
20 | Correct | 2 ms | 344 KB | Output is correct |
21 | Correct | 2 ms | 344 KB | Output is correct |
22 | Correct | 1 ms | 344 KB | Output is correct |
23 | Correct | 7 ms | 600 KB | Output is correct |
24 | Correct | 3 ms | 344 KB | Output is correct |
25 | Correct | 11 ms | 600 KB | Output is correct |
26 | Correct | 12 ms | 600 KB | Output is correct |
27 | Correct | 19 ms | 428 KB | Output is correct |
28 | Correct | 7 ms | 696 KB | Output is correct |
29 | Correct | 9 ms | 344 KB | Output is correct |
30 | Correct | 10 ms | 344 KB | Output is correct |
31 | Correct | 10 ms | 592 KB | Output is correct |
32 | Correct | 10 ms | 592 KB | Output is correct |
33 | Correct | 12 ms | 592 KB | Output is correct |
34 | Correct | 10 ms | 600 KB | Output is correct |
35 | Correct | 11 ms | 536 KB | Output is correct |
36 | Correct | 11 ms | 344 KB | Output is correct |
37 | Correct | 11 ms | 600 KB | Output is correct |
38 | Correct | 10 ms | 344 KB | Output is correct |
39 | Correct | 11 ms | 600 KB | Output is correct |
40 | Correct | 7 ms | 600 KB | Output is correct |
41 | Correct | 5 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 17 ms | 684 KB | Output is correct |
8 | Correct | 10 ms | 700 KB | Output is correct |
9 | Correct | 21 ms | 848 KB | Output is correct |
10 | Correct | 34 ms | 684 KB | Output is correct |
11 | Correct | 24 ms | 596 KB | Output is correct |
12 | Correct | 19 ms | 712 KB | Output is correct |
13 | Correct | 31 ms | 848 KB | Output is correct |
14 | Correct | 34 ms | 684 KB | Output is correct |
15 | Correct | 35 ms | 1180 KB | Output is correct |
16 | Correct | 24 ms | 884 KB | Output is correct |
17 | Correct | 31 ms | 924 KB | Output is correct |
18 | Correct | 25 ms | 860 KB | Output is correct |
19 | Correct | 21 ms | 960 KB | Output is correct |
20 | Correct | 18 ms | 960 KB | Output is correct |
21 | Correct | 23 ms | 848 KB | Output is correct |
22 | Correct | 34 ms | 664 KB | Output is correct |
23 | Correct | 32 ms | 852 KB | Output is correct |
24 | Correct | 19 ms | 712 KB | Output is correct |
25 | Correct | 14 ms | 860 KB | Output is correct |
26 | Correct | 9 ms | 600 KB | Output is correct |
27 | Correct | 28 ms | 684 KB | Output is correct |
28 | Correct | 15 ms | 592 KB | Output is correct |
29 | Correct | 32 ms | 848 KB | Output is correct |
30 | Correct | 45 ms | 848 KB | Output is correct |
31 | Correct | 26 ms | 864 KB | Output is correct |
32 | Correct | 35 ms | 908 KB | Output is correct |
33 | Correct | 32 ms | 848 KB | Output is correct |
34 | Correct | 26 ms | 848 KB | Output is correct |
35 | Partially correct | 34 ms | 624 KB | Output is partially correct |
36 | Correct | 29 ms | 848 KB | Output is correct |
37 | Correct | 27 ms | 816 KB | Output is correct |
38 | Correct | 36 ms | 848 KB | Output is correct |
39 | Correct | 36 ms | 848 KB | Output is correct |
40 | Correct | 12 ms | 652 KB | Output is correct |
41 | Correct | 25 ms | 848 KB | Output is correct |
42 | Partially correct | 31 ms | 596 KB | Output is partially correct |
43 | Correct | 4 ms | 344 KB | Output is correct |
44 | Correct | 23 ms | 592 KB | Output is correct |
45 | Correct | 14 ms | 880 KB | Output is correct |
46 | Correct | 13 ms | 600 KB | Output is correct |
47 | Correct | 16 ms | 728 KB | Output is correct |
48 | Correct | 10 ms | 600 KB | Output is correct |