#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
int min_cardinality(int N){
vector<int> active;
int cnt = 0;
for (int i = 0; i < N; i++){
move_inside(i);
if (press_button() == 1) cnt++;
else{
move_outside(i); active.push_back(i);
}
}
int ans = 1, l = 2, r = N / cnt, sz = cnt;
while (l <= r){
int m = (l + r) >> 1;
vector<int> iv, ov;
for (int i : active){
move_inside(i);
if (press_button() <= m){
iv.push_back(i); sz++;
}
else{
move_outside(i); ov.push_back(i);
}
if (sz == cnt * m) break;
}
if (sz == cnt * m){
ans = m; l = m + 1;
active = ov;
}
else{
r = m - 1;
for (int i : iv) move_outside(i);
sz -= iv.size();
active = iv;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
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 |
356 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
1 ms |
344 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
356 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
1 ms |
344 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Incorrect |
0 ms |
344 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |