#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int min_cardinality(int N) {
n = N;
vector<int> v, in, out;
for(int i=0; i<n; i++){
move_inside(i);
v.push_back(i);
if(press_button()>=2){
move_outside(i);
v.pop_back();
out.push_back(i);
}
}
int lb = 0, rb = n / v.size();
while(lb<rb){
int mb = (lb+rb+1)/2;
vector<int> nout;
for(auto x:out){
if(v.size()*mb==in.size()){
nout.push_back(x);
}else{
move_inside(x);
if(press_button()>mb+1){
move_outside(x);
nout.push_back(x);
}else{
in.push_back(x);
}
}
}
if(v.size()*mb==in.size()){
lb=mb;
out=nout;
}else{
rb=mb-1;
out = in;
for(auto x:in) move_outside(x);
in.clear();
}
}
return lb+1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
600 KB |
Output is correct |
10 |
Correct |
2 ms |
500 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
3 ms |
600 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
3 ms |
344 KB |
Output is correct |
16 |
Correct |
3 ms |
344 KB |
Output is correct |
17 |
Correct |
4 ms |
600 KB |
Output is correct |
18 |
Correct |
2 ms |
344 KB |
Output is correct |
19 |
Correct |
3 ms |
596 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 |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
600 KB |
Output is correct |
10 |
Correct |
2 ms |
500 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
3 ms |
600 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
3 ms |
344 KB |
Output is correct |
16 |
Correct |
3 ms |
344 KB |
Output is correct |
17 |
Correct |
4 ms |
600 KB |
Output is correct |
18 |
Correct |
2 ms |
344 KB |
Output is correct |
19 |
Correct |
3 ms |
596 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 |
600 KB |
Output is correct |
23 |
Correct |
8 ms |
600 KB |
Output is correct |
24 |
Correct |
6 ms |
688 KB |
Output is correct |
25 |
Correct |
11 ms |
756 KB |
Output is correct |
26 |
Correct |
20 ms |
924 KB |
Output is correct |
27 |
Correct |
12 ms |
696 KB |
Output is correct |
28 |
Correct |
11 ms |
688 KB |
Output is correct |
29 |
Correct |
16 ms |
688 KB |
Output is correct |
30 |
Correct |
14 ms |
680 KB |
Output is correct |
31 |
Correct |
16 ms |
856 KB |
Output is correct |
32 |
Correct |
24 ms |
692 KB |
Output is correct |
33 |
Correct |
18 ms |
940 KB |
Output is correct |
34 |
Correct |
16 ms |
856 KB |
Output is correct |
35 |
Correct |
14 ms |
684 KB |
Output is correct |
36 |
Correct |
14 ms |
928 KB |
Output is correct |
37 |
Correct |
18 ms |
600 KB |
Output is correct |
38 |
Correct |
14 ms |
856 KB |
Output is correct |
39 |
Correct |
13 ms |
692 KB |
Output is correct |
40 |
Correct |
7 ms |
864 KB |
Output is correct |
41 |
Correct |
7 ms |
700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
21 ms |
856 KB |
Output is correct |
8 |
Correct |
9 ms |
600 KB |
Output is correct |
9 |
Correct |
25 ms |
864 KB |
Output is correct |
10 |
Correct |
30 ms |
692 KB |
Output is correct |
11 |
Correct |
25 ms |
856 KB |
Output is correct |
12 |
Correct |
13 ms |
600 KB |
Output is correct |
13 |
Correct |
30 ms |
860 KB |
Output is correct |
14 |
Correct |
25 ms |
700 KB |
Output is correct |
15 |
Partially correct |
43 ms |
700 KB |
Output is partially correct |
16 |
Partially correct |
41 ms |
684 KB |
Output is partially correct |
17 |
Partially correct |
41 ms |
928 KB |
Output is partially correct |
18 |
Partially correct |
38 ms |
684 KB |
Output is partially correct |
19 |
Partially correct |
27 ms |
684 KB |
Output is partially correct |
20 |
Partially correct |
35 ms |
856 KB |
Output is partially correct |
21 |
Partially correct |
36 ms |
1108 KB |
Output is partially correct |
22 |
Correct |
36 ms |
1112 KB |
Output is correct |
23 |
Correct |
30 ms |
856 KB |
Output is correct |
24 |
Correct |
18 ms |
692 KB |
Output is correct |
25 |
Correct |
13 ms |
936 KB |
Output is correct |
26 |
Correct |
12 ms |
944 KB |
Output is correct |
27 |
Correct |
36 ms |
856 KB |
Output is correct |
28 |
Correct |
18 ms |
608 KB |
Output is correct |
29 |
Correct |
28 ms |
944 KB |
Output is correct |
30 |
Correct |
27 ms |
600 KB |
Output is correct |
31 |
Correct |
25 ms |
600 KB |
Output is correct |
32 |
Partially correct |
27 ms |
696 KB |
Output is partially correct |
33 |
Correct |
22 ms |
600 KB |
Output is correct |
34 |
Correct |
28 ms |
936 KB |
Output is correct |
35 |
Correct |
27 ms |
948 KB |
Output is correct |
36 |
Correct |
23 ms |
856 KB |
Output is correct |
37 |
Partially correct |
42 ms |
856 KB |
Output is partially correct |
38 |
Partially correct |
33 ms |
860 KB |
Output is partially correct |
39 |
Correct |
27 ms |
856 KB |
Output is correct |
40 |
Correct |
18 ms |
1108 KB |
Output is correct |
41 |
Correct |
25 ms |
676 KB |
Output is correct |
42 |
Correct |
29 ms |
600 KB |
Output is correct |
43 |
Correct |
6 ms |
856 KB |
Output is correct |
44 |
Correct |
23 ms |
696 KB |
Output is correct |
45 |
Correct |
16 ms |
856 KB |
Output is correct |
46 |
Correct |
14 ms |
856 KB |
Output is correct |
47 |
Correct |
12 ms |
852 KB |
Output is correct |
48 |
Correct |
18 ms |
860 KB |
Output is correct |