#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())
break;
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 |
1 ms |
344 KB |
Output is correct |
6 |
Incorrect |
3 ms |
344 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
344 KB |
Output is correct |
6 |
Incorrect |
3 ms |
344 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Incorrect |
58 ms |
1432 KB |
Wrong answer. |
8 |
Halted |
0 ms |
0 KB |
- |