#include <bits/stdc++.h>
using namespace std;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "insects.h"
int min_cardinality(int n) {
set<int> olan;
for (int i = 0; i < n; ++i)
{
olan.insert(i);
}
vector<int> aldim;
vector<int> almadim;
function<int(int)> calc;
calc = [&](int x)->int{
aldim.clear();
almadim.clear();
int ans = 0;
for (auto it : olan){
move_inside(it);
if (press_button()>x){
move_outside(it);
almadim.push_back(it);
}
else {
aldim.push_back(it);
ans++;
}
}
for (auto &it : aldim){
move_outside(it);
}
return ans;
};
int diff = calc(1);
int l = 2, r = (n/diff)+1;
int hueh = 0;
while (l<r){
int mid = l+(r-l)/2;
int crr = calc(mid-hueh);
if (crr==(mid-hueh)*diff){
l=mid+1;
hueh=mid;
while (aldim.size()){
olan.erase(aldim.back());
aldim.pop_back();
}
}
else {
r=mid;
while (almadim.size()){
olan.erase(almadim.back());
almadim.pop_back();
}
}
}
return l-1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
312 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
5 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
208 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
5 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
208 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
4 ms |
208 KB |
Output is correct |
17 |
Correct |
2 ms |
312 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
4 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
312 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
5 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
208 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
5 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
208 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
4 ms |
208 KB |
Output is correct |
17 |
Correct |
2 ms |
312 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
4 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
23 ms |
336 KB |
Output is correct |
24 |
Correct |
7 ms |
352 KB |
Output is correct |
25 |
Correct |
22 ms |
336 KB |
Output is correct |
26 |
Correct |
25 ms |
336 KB |
Output is correct |
27 |
Correct |
16 ms |
356 KB |
Output is correct |
28 |
Correct |
8 ms |
336 KB |
Output is correct |
29 |
Correct |
23 ms |
336 KB |
Output is correct |
30 |
Correct |
22 ms |
352 KB |
Output is correct |
31 |
Correct |
18 ms |
336 KB |
Output is correct |
32 |
Correct |
23 ms |
348 KB |
Output is correct |
33 |
Correct |
27 ms |
336 KB |
Output is correct |
34 |
Correct |
19 ms |
336 KB |
Output is correct |
35 |
Correct |
19 ms |
336 KB |
Output is correct |
36 |
Correct |
11 ms |
336 KB |
Output is correct |
37 |
Correct |
17 ms |
352 KB |
Output is correct |
38 |
Correct |
18 ms |
356 KB |
Output is correct |
39 |
Correct |
20 ms |
356 KB |
Output is correct |
40 |
Correct |
19 ms |
336 KB |
Output is correct |
41 |
Correct |
9 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
42 ms |
400 KB |
Output is correct |
8 |
Correct |
14 ms |
468 KB |
Output is correct |
9 |
Correct |
36 ms |
524 KB |
Output is correct |
10 |
Correct |
33 ms |
396 KB |
Output is correct |
11 |
Correct |
43 ms |
336 KB |
Output is correct |
12 |
Correct |
19 ms |
396 KB |
Output is correct |
13 |
Correct |
36 ms |
400 KB |
Output is correct |
14 |
Partially correct |
35 ms |
404 KB |
Output is partially correct |
15 |
Correct |
52 ms |
400 KB |
Output is correct |
16 |
Correct |
35 ms |
404 KB |
Output is correct |
17 |
Correct |
46 ms |
408 KB |
Output is correct |
18 |
Correct |
51 ms |
336 KB |
Output is correct |
19 |
Correct |
35 ms |
404 KB |
Output is correct |
20 |
Correct |
41 ms |
336 KB |
Output is correct |
21 |
Correct |
31 ms |
400 KB |
Output is correct |
22 |
Correct |
36 ms |
400 KB |
Output is correct |
23 |
Partially correct |
43 ms |
336 KB |
Output is partially correct |
24 |
Correct |
36 ms |
528 KB |
Output is correct |
25 |
Correct |
27 ms |
404 KB |
Output is correct |
26 |
Correct |
14 ms |
336 KB |
Output is correct |
27 |
Correct |
33 ms |
336 KB |
Output is correct |
28 |
Correct |
49 ms |
384 KB |
Output is correct |
29 |
Correct |
38 ms |
400 KB |
Output is correct |
30 |
Correct |
26 ms |
516 KB |
Output is correct |
31 |
Correct |
42 ms |
400 KB |
Output is correct |
32 |
Correct |
48 ms |
404 KB |
Output is correct |
33 |
Partially correct |
46 ms |
396 KB |
Output is partially correct |
34 |
Partially correct |
58 ms |
400 KB |
Output is partially correct |
35 |
Correct |
38 ms |
336 KB |
Output is correct |
36 |
Correct |
44 ms |
396 KB |
Output is correct |
37 |
Correct |
52 ms |
400 KB |
Output is correct |
38 |
Correct |
30 ms |
404 KB |
Output is correct |
39 |
Correct |
41 ms |
408 KB |
Output is correct |
40 |
Correct |
36 ms |
400 KB |
Output is correct |
41 |
Correct |
51 ms |
336 KB |
Output is correct |
42 |
Correct |
35 ms |
412 KB |
Output is correct |
43 |
Correct |
10 ms |
328 KB |
Output is correct |
44 |
Correct |
28 ms |
396 KB |
Output is correct |
45 |
Correct |
52 ms |
336 KB |
Output is correct |
46 |
Correct |
23 ms |
396 KB |
Output is correct |
47 |
Correct |
26 ms |
336 KB |
Output is correct |
48 |
Correct |
27 ms |
396 KB |
Output is correct |