#include "insects.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,tune=native")
using namespace std;
using namespace __gnu_pbds;
typedef int ll;
typedef long long LL;
typedef long double ld;
#define el "\n"
#define se " "
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mkp make_pair
#define srt(x,y) sort(x+1,x+1+y)
#define srtt(x,y,cmp) sort(x+1,x+1+y,cmp)
#define rev(x,y) reverse(x+1,x+1+y)
#define revv(x,y,cmp) reverse(x+1,x+1+y,cmp)
#define print(x) for (auto it : x) cout<<it<<se
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
const ll NN=2000+9;
const ll NNN=109;
const ll INF=1e9;
const ld PI=3.141592653589793238462643;
const ll MOD=1e9+7;
ll zero=0;
ll a,b,c,d,a1,b1,c1,val,i,sum1,j,n,m,pos,ans,sum,cur,res,ans1,res1;
ll k,kk,kkk,cnt,cnt1,l,r,x,y,mn,t,fl,q;
bool used[4009];
deque<ll>dek;
int min_cardinality(int N) {
ll ans=N;
for(ll i=0;i<N;i++){
move_inside(i),dek.pb(i);
if(press_button()>1){
ans--;
move_outside(i),dek.pop_back();
}
}
while(!dek.empty()){
// cout<<dek.front()<<se;
move_outside(dek.front()),dek.pop_front();
}
// cout<<"SDS "<<dek.size()<<el;
if(ans==N || N/ans<=1) return 1;
ll l=2,r=N/ans;
ll cur=1;
while(r-l>=0){
ll mid=(l+r)>>1;
for(ll i=0;i<N;i++){
move_inside(i),dek.pb(i);
if(press_button()>mid) move_outside(i),dek.pop_back();
}
// cout<<dek.size()<<" DEK\n";
if(ans*mid==dek.size()) cur=mid,l=mid+1;
else r=mid-1;
while(!dek.empty()){
move_outside(dek.front()),dek.pop_front();
}
}
return cur;
}
Compilation message
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:67:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | if(ans*mid==dek.size()) cur=mid,l=mid+1;
| ~~~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
17 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
11 ms |
208 KB |
Output is correct |
9 |
Correct |
10 ms |
208 KB |
Output is correct |
10 |
Correct |
12 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
10 ms |
208 KB |
Output is correct |
13 |
Correct |
8 ms |
208 KB |
Output is correct |
14 |
Correct |
11 ms |
208 KB |
Output is correct |
15 |
Correct |
8 ms |
208 KB |
Output is correct |
16 |
Correct |
9 ms |
208 KB |
Output is correct |
17 |
Correct |
8 ms |
208 KB |
Output is correct |
18 |
Correct |
8 ms |
208 KB |
Output is correct |
19 |
Correct |
6 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
4 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
17 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
11 ms |
208 KB |
Output is correct |
9 |
Correct |
10 ms |
208 KB |
Output is correct |
10 |
Correct |
12 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
10 ms |
208 KB |
Output is correct |
13 |
Correct |
8 ms |
208 KB |
Output is correct |
14 |
Correct |
11 ms |
208 KB |
Output is correct |
15 |
Correct |
8 ms |
208 KB |
Output is correct |
16 |
Correct |
9 ms |
208 KB |
Output is correct |
17 |
Correct |
8 ms |
208 KB |
Output is correct |
18 |
Correct |
8 ms |
208 KB |
Output is correct |
19 |
Correct |
6 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
4 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
97 ms |
408 KB |
Output is correct |
24 |
Correct |
8 ms |
208 KB |
Output is correct |
25 |
Correct |
47 ms |
292 KB |
Output is correct |
26 |
Correct |
47 ms |
304 KB |
Output is correct |
27 |
Correct |
88 ms |
208 KB |
Output is correct |
28 |
Correct |
11 ms |
208 KB |
Output is correct |
29 |
Correct |
66 ms |
208 KB |
Output is correct |
30 |
Correct |
43 ms |
208 KB |
Output is correct |
31 |
Correct |
75 ms |
208 KB |
Output is correct |
32 |
Correct |
70 ms |
336 KB |
Output is correct |
33 |
Correct |
53 ms |
208 KB |
Output is correct |
34 |
Correct |
74 ms |
280 KB |
Output is correct |
35 |
Correct |
57 ms |
208 KB |
Output is correct |
36 |
Correct |
35 ms |
412 KB |
Output is correct |
37 |
Correct |
39 ms |
208 KB |
Output is correct |
38 |
Correct |
33 ms |
208 KB |
Output is correct |
39 |
Correct |
24 ms |
208 KB |
Output is correct |
40 |
Correct |
20 ms |
208 KB |
Output is correct |
41 |
Correct |
9 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Partially correct |
1 ms |
208 KB |
Output is partially correct |
7 |
Partially correct |
215 ms |
320 KB |
Output is partially correct |
8 |
Correct |
19 ms |
312 KB |
Output is correct |
9 |
Partially correct |
124 ms |
292 KB |
Output is partially correct |
10 |
Partially correct |
115 ms |
420 KB |
Output is partially correct |
11 |
Partially correct |
179 ms |
288 KB |
Output is partially correct |
12 |
Correct |
32 ms |
292 KB |
Output is correct |
13 |
Partially correct |
88 ms |
296 KB |
Output is partially correct |
14 |
Partially correct |
102 ms |
208 KB |
Output is partially correct |
15 |
Partially correct |
134 ms |
416 KB |
Output is partially correct |
16 |
Partially correct |
188 ms |
296 KB |
Output is partially correct |
17 |
Partially correct |
148 ms |
380 KB |
Output is partially correct |
18 |
Partially correct |
138 ms |
284 KB |
Output is partially correct |
19 |
Partially correct |
158 ms |
376 KB |
Output is partially correct |
20 |
Partially correct |
157 ms |
292 KB |
Output is partially correct |
21 |
Partially correct |
93 ms |
292 KB |
Output is partially correct |
22 |
Partially correct |
47 ms |
296 KB |
Output is partially correct |
23 |
Partially correct |
73 ms |
284 KB |
Output is partially correct |
24 |
Correct |
42 ms |
300 KB |
Output is correct |
25 |
Correct |
38 ms |
300 KB |
Output is correct |
26 |
Correct |
15 ms |
208 KB |
Output is correct |
27 |
Partially correct |
79 ms |
208 KB |
Output is partially correct |
28 |
Partially correct |
114 ms |
396 KB |
Output is partially correct |
29 |
Partially correct |
87 ms |
412 KB |
Output is partially correct |
30 |
Partially correct |
106 ms |
412 KB |
Output is partially correct |
31 |
Partially correct |
112 ms |
296 KB |
Output is partially correct |
32 |
Partially correct |
88 ms |
288 KB |
Output is partially correct |
33 |
Partially correct |
94 ms |
296 KB |
Output is partially correct |
34 |
Partially correct |
78 ms |
292 KB |
Output is partially correct |
35 |
Partially correct |
128 ms |
284 KB |
Output is partially correct |
36 |
Partially correct |
127 ms |
208 KB |
Output is partially correct |
37 |
Partially correct |
94 ms |
296 KB |
Output is partially correct |
38 |
Partially correct |
106 ms |
288 KB |
Output is partially correct |
39 |
Partially correct |
95 ms |
284 KB |
Output is partially correct |
40 |
Partially correct |
96 ms |
208 KB |
Output is partially correct |
41 |
Partially correct |
141 ms |
288 KB |
Output is partially correct |
42 |
Partially correct |
133 ms |
292 KB |
Output is partially correct |
43 |
Partially correct |
28 ms |
208 KB |
Output is partially correct |
44 |
Partially correct |
124 ms |
208 KB |
Output is partially correct |
45 |
Partially correct |
196 ms |
284 KB |
Output is partially correct |
46 |
Correct |
30 ms |
208 KB |
Output is correct |
47 |
Correct |
30 ms |
300 KB |
Output is correct |
48 |
Correct |
34 ms |
208 KB |
Output is correct |