#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;
set<int> s,t;
int n;
int k=0;
int BS(int l,int r){
if(l==r)return l;
t=s;
int m=(l+r)/2+1;
REP(i,0,n){
if(s.count(i))continue;
s.insert(i);
move_inside(i);
if(press_button()<=m)continue;
s.erase(i);
move_outside(i);
}
int p=s.size();
if(p==m*k)return BS(m,min(r,m+(n-p)/k));
else {
for(auto u:s)if(t.count(u)==0)move_outside(u);
s=t;
return BS(l,m-1);
}
}
int min_cardinality(int N) {
n=N;
REP(i,0,n){
move_inside(i);k++;
if(press_button()>1){
move_outside(i);k--;
}
}
int r=N/k;
int ans=BS(1,r);
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 |
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 |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
444 KB |
Output is correct |
9 |
Correct |
5 ms |
436 KB |
Output is correct |
10 |
Correct |
7 ms |
436 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
8 ms |
344 KB |
Output is correct |
13 |
Correct |
7 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
600 KB |
Output is correct |
16 |
Correct |
4 ms |
344 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
18 |
Correct |
4 ms |
436 KB |
Output is correct |
19 |
Correct |
3 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
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 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
444 KB |
Output is correct |
9 |
Correct |
5 ms |
436 KB |
Output is correct |
10 |
Correct |
7 ms |
436 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
8 ms |
344 KB |
Output is correct |
13 |
Correct |
7 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
600 KB |
Output is correct |
16 |
Correct |
4 ms |
344 KB |
Output is correct |
17 |
Correct |
5 ms |
344 KB |
Output is correct |
18 |
Correct |
4 ms |
436 KB |
Output is correct |
19 |
Correct |
3 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
23 |
Correct |
11 ms |
344 KB |
Output is correct |
24 |
Correct |
6 ms |
344 KB |
Output is correct |
25 |
Correct |
18 ms |
688 KB |
Output is correct |
26 |
Correct |
12 ms |
448 KB |
Output is correct |
27 |
Correct |
64 ms |
344 KB |
Output is correct |
28 |
Correct |
5 ms |
344 KB |
Output is correct |
29 |
Correct |
30 ms |
344 KB |
Output is correct |
30 |
Correct |
30 ms |
344 KB |
Output is correct |
31 |
Correct |
26 ms |
344 KB |
Output is correct |
32 |
Correct |
17 ms |
448 KB |
Output is correct |
33 |
Correct |
15 ms |
436 KB |
Output is correct |
34 |
Correct |
14 ms |
460 KB |
Output is correct |
35 |
Correct |
17 ms |
856 KB |
Output is correct |
36 |
Correct |
27 ms |
344 KB |
Output is correct |
37 |
Correct |
14 ms |
600 KB |
Output is correct |
38 |
Correct |
26 ms |
680 KB |
Output is correct |
39 |
Correct |
27 ms |
600 KB |
Output is correct |
40 |
Correct |
6 ms |
344 KB |
Output is correct |
41 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
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 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
29 ms |
532 KB |
Output is correct |
8 |
Correct |
12 ms |
344 KB |
Output is correct |
9 |
Correct |
28 ms |
680 KB |
Output is correct |
10 |
Partially correct |
53 ms |
1216 KB |
Output is partially correct |
11 |
Partially correct |
147 ms |
588 KB |
Output is partially correct |
12 |
Correct |
18 ms |
592 KB |
Output is correct |
13 |
Partially correct |
129 ms |
592 KB |
Output is partially correct |
14 |
Partially correct |
88 ms |
344 KB |
Output is partially correct |
15 |
Partially correct |
30 ms |
564 KB |
Output is partially correct |
16 |
Partially correct |
38 ms |
664 KB |
Output is partially correct |
17 |
Partially correct |
32 ms |
528 KB |
Output is partially correct |
18 |
Partially correct |
33 ms |
668 KB |
Output is partially correct |
19 |
Partially correct |
50 ms |
848 KB |
Output is partially correct |
20 |
Partially correct |
47 ms |
684 KB |
Output is partially correct |
21 |
Partially correct |
43 ms |
592 KB |
Output is partially correct |
22 |
Partially correct |
56 ms |
456 KB |
Output is partially correct |
23 |
Partially correct |
53 ms |
344 KB |
Output is partially correct |
24 |
Correct |
29 ms |
668 KB |
Output is correct |
25 |
Correct |
24 ms |
688 KB |
Output is correct |
26 |
Correct |
8 ms |
344 KB |
Output is correct |
27 |
Correct |
25 ms |
560 KB |
Output is correct |
28 |
Correct |
51 ms |
972 KB |
Output is correct |
29 |
Correct |
43 ms |
436 KB |
Output is correct |
30 |
Correct |
33 ms |
516 KB |
Output is correct |
31 |
Partially correct |
64 ms |
668 KB |
Output is partially correct |
32 |
Partially correct |
58 ms |
600 KB |
Output is partially correct |
33 |
Partially correct |
51 ms |
436 KB |
Output is partially correct |
34 |
Partially correct |
61 ms |
436 KB |
Output is partially correct |
35 |
Correct |
20 ms |
692 KB |
Output is correct |
36 |
Correct |
43 ms |
436 KB |
Output is correct |
37 |
Partially correct |
39 ms |
592 KB |
Output is partially correct |
38 |
Partially correct |
55 ms |
592 KB |
Output is partially correct |
39 |
Correct |
28 ms |
344 KB |
Output is correct |
40 |
Correct |
25 ms |
736 KB |
Output is correct |
41 |
Correct |
32 ms |
600 KB |
Output is correct |
42 |
Correct |
31 ms |
736 KB |
Output is correct |
43 |
Partially correct |
19 ms |
436 KB |
Output is partially correct |
44 |
Partially correct |
105 ms |
424 KB |
Output is partially correct |
45 |
Correct |
23 ms |
612 KB |
Output is correct |
46 |
Correct |
19 ms |
436 KB |
Output is correct |
47 |
Correct |
13 ms |
432 KB |
Output is correct |
48 |
Correct |
22 ms |
428 KB |
Output is correct |