#include<bits/stdc++.h>
#include "insects.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int min_cardinality(int n){
int d=0;
vector<bool>used(n,0);
for(int i=0;i<n;i++){
d++;
move_inside(i);
int cnt=press_button();
if(cnt>1){
move_outside(i);
d--;
}
else{
used[i]=true;
}
}
int l=1,r=n/d;
int last=1;
while(l<r){
int mid=(l+r+1)/2;
vector<int>added;
int len=last*d;
for(int i=0;i<n;i++){
if(!used[i]){
move_inside(i);
if(press_button()>mid){
move_outside(i);
}
else{
len++;
added.pb(i);
}
}
}
if(len==mid*d){
for(int i:added){
used[i]=true;
}
l=mid;
last=mid;
}
else{
r=mid-1;
}
}
return last;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
380 KB |
Output is correct |
9 |
Incorrect |
3 ms |
344 KB |
Wrong answer. |
10 |
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 |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
380 KB |
Output is correct |
9 |
Incorrect |
3 ms |
344 KB |
Wrong answer. |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
30 ms |
596 KB |
Output is correct |
8 |
Correct |
9 ms |
344 KB |
Output is correct |
9 |
Correct |
35 ms |
432 KB |
Output is correct |
10 |
Partially correct |
44 ms |
340 KB |
Output is partially correct |
11 |
Partially correct |
132 ms |
408 KB |
Output is partially correct |
12 |
Correct |
9 ms |
344 KB |
Output is correct |
13 |
Partially correct |
117 ms |
344 KB |
Output is partially correct |
14 |
Partially correct |
56 ms |
344 KB |
Output is partially correct |
15 |
Incorrect |
28 ms |
344 KB |
Wrong answer. |
16 |
Halted |
0 ms |
0 KB |
- |