#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a), end(a)
using vi = vector<int>;
int D, inside[3000];
int min_cardinality(int n) {
for(int i = 0; i < n; i++){
move_inside(i);
if(press_button()>1) move_outside(i);
else inside[i]=1, D++;
}
int l = 1, r = n/D, p=1;
while(l<r){
int mid = (l+r+1)/2, tot=n;
vi undo; undo.clear();
for(int i = 0; i < n; i++)
if(inside[i] > mid and mid<p)
move_outside(i), inside[i]=0, tot--;
for(int i = 0; i < n; i++){
if(inside[i] or tot==D*mid) continue;
if(press_button()>mid) move_outside(i);
else inside[i]=mid, tot++, undo.pb(i);
}
if(tot==D*mid) l = mid;
else{
for(auto u : undo) move_outside(u);
r=mid-1;
}
p=mid;
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Incorrect |
0 ms |
344 KB |
Wrong answer. |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Incorrect |
0 ms |
344 KB |
Wrong answer. |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |