#include<bits/stdc++.h>
#include "insects.h"
//#pragma GCC optimize ("O3")
using namespace std;
#define el "\n"
#define se " "
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
const ll INF=1e18,ch=1e18;
ll a,b,c,d,n,COST,t,last,ab,ba,n1,n2,fl1,fl2,o1,o2,flag,flag1,flag2,g,m,m1,m2,i,j,lr,f,k,l,r,y,o,p,mx=-ch,mx1=-ch,mx2=-ch,q,q1,q2,q3,q4,mn=ch,mn1=ch,mn2=ch,f1,f2,f3,pos,ans,sum,sz=1,MOD=1e9+7,zero=0,a1,b1,c1,val,sum1,cur,res,ans1,res1,kk,kkk,cnt,cnt1,fl;
ll S[2005];
ll A[2005];
//void move_inside(int i)
//void move_outside(int i)
//int press_button()
bool pr(ll m)
{
ans=0;
for(i=0;i<n;i++)
{
if (S[i]==1) continue;
move_inside(i);
A[i]=1;
if (press_button()+q>m)
{
A[i]=0;
move_outside(i);
}
else
{
ans++;
}
}
if ((m-q)*d==ans) return 1;
return 0;
}
int min_cardinality(int N)
{
n=N;
d=0;
for(i=0;i<n;i++)
{
move_inside(i);
d++;S[i]=1;
if (press_button()>1)
{
move_outside(i);
d--;S[i]=0;
}
}
for(i=0;i<n;i++)
{
if (S[i]==1) move_outside(i);
}
o=1;l=2;r=n/d-1;q=1;
while(l<=r)
{
for(i=0;i<n;i++)
{
A[i]=0;
}
m=(l+r)/2;
if (pr(m)==1)
{
o=m;
l=m+1;
q=m;
for(i=0;i<n;i++)
{
if (A[i]==1)
{
S[i]=1;
move_outside(i);
}
}
}
else
{
r=m-1;
for(i=0;i<n;i++)
{
if (A[i]==1)
{
move_outside(i);
}
}
}
}
if (o==n/d-1)
{
for(i=0;i<n;i++)
{
A[i]=0;
}
if (pr(n/d)==1) o=n/d;
}
return o;
}
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
5 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 |
9 ms |
208 KB |
Output is correct |
13 |
Correct |
7 ms |
208 KB |
Output is correct |
14 |
Correct |
4 ms |
208 KB |
Output is correct |
15 |
Correct |
7 ms |
208 KB |
Output is correct |
16 |
Correct |
6 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
9 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
5 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 |
9 ms |
208 KB |
Output is correct |
13 |
Correct |
7 ms |
208 KB |
Output is correct |
14 |
Correct |
4 ms |
208 KB |
Output is correct |
15 |
Correct |
7 ms |
208 KB |
Output is correct |
16 |
Correct |
6 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
9 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
30 ms |
308 KB |
Output is correct |
24 |
Correct |
10 ms |
308 KB |
Output is correct |
25 |
Correct |
32 ms |
304 KB |
Output is correct |
26 |
Correct |
40 ms |
304 KB |
Output is correct |
27 |
Correct |
56 ms |
320 KB |
Output is correct |
28 |
Correct |
10 ms |
208 KB |
Output is correct |
29 |
Correct |
87 ms |
308 KB |
Output is correct |
30 |
Correct |
34 ms |
312 KB |
Output is correct |
31 |
Correct |
31 ms |
208 KB |
Output is correct |
32 |
Correct |
33 ms |
308 KB |
Output is correct |
33 |
Correct |
37 ms |
208 KB |
Output is correct |
34 |
Correct |
34 ms |
304 KB |
Output is correct |
35 |
Correct |
30 ms |
312 KB |
Output is correct |
36 |
Correct |
28 ms |
308 KB |
Output is correct |
37 |
Correct |
32 ms |
312 KB |
Output is correct |
38 |
Correct |
31 ms |
208 KB |
Output is correct |
39 |
Correct |
20 ms |
208 KB |
Output is correct |
40 |
Correct |
12 ms |
208 KB |
Output is correct |
41 |
Correct |
8 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
52 ms |
432 KB |
Output is correct |
8 |
Correct |
16 ms |
208 KB |
Output is correct |
9 |
Partially correct |
33 ms |
316 KB |
Output is partially correct |
10 |
Partially correct |
93 ms |
296 KB |
Output is partially correct |
11 |
Partially correct |
98 ms |
208 KB |
Output is partially correct |
12 |
Correct |
23 ms |
304 KB |
Output is correct |
13 |
Partially correct |
184 ms |
304 KB |
Output is partially correct |
14 |
Partially correct |
96 ms |
304 KB |
Output is partially correct |
15 |
Partially correct |
62 ms |
308 KB |
Output is partially correct |
16 |
Partially correct |
49 ms |
208 KB |
Output is partially correct |
17 |
Partially correct |
73 ms |
300 KB |
Output is partially correct |
18 |
Partially correct |
67 ms |
308 KB |
Output is partially correct |
19 |
Partially correct |
42 ms |
208 KB |
Output is partially correct |
20 |
Partially correct |
62 ms |
308 KB |
Output is partially correct |
21 |
Partially correct |
99 ms |
312 KB |
Output is partially correct |
22 |
Partially correct |
72 ms |
308 KB |
Output is partially correct |
23 |
Partially correct |
74 ms |
300 KB |
Output is partially correct |
24 |
Correct |
35 ms |
308 KB |
Output is correct |
25 |
Correct |
33 ms |
304 KB |
Output is correct |
26 |
Correct |
17 ms |
312 KB |
Output is correct |
27 |
Partially correct |
58 ms |
312 KB |
Output is partially correct |
28 |
Partially correct |
46 ms |
312 KB |
Output is partially correct |
29 |
Partially correct |
59 ms |
316 KB |
Output is partially correct |
30 |
Partially correct |
57 ms |
316 KB |
Output is partially correct |
31 |
Partially correct |
72 ms |
300 KB |
Output is partially correct |
32 |
Partially correct |
46 ms |
304 KB |
Output is partially correct |
33 |
Partially correct |
89 ms |
208 KB |
Output is partially correct |
34 |
Partially correct |
87 ms |
304 KB |
Output is partially correct |
35 |
Partially correct |
47 ms |
208 KB |
Output is partially correct |
36 |
Partially correct |
55 ms |
312 KB |
Output is partially correct |
37 |
Partially correct |
73 ms |
416 KB |
Output is partially correct |
38 |
Partially correct |
71 ms |
300 KB |
Output is partially correct |
39 |
Partially correct |
26 ms |
312 KB |
Output is partially correct |
40 |
Partially correct |
59 ms |
208 KB |
Output is partially correct |
41 |
Partially correct |
50 ms |
300 KB |
Output is partially correct |
42 |
Partially correct |
53 ms |
312 KB |
Output is partially correct |
43 |
Partially correct |
39 ms |
308 KB |
Output is partially correct |
44 |
Partially correct |
149 ms |
304 KB |
Output is partially correct |
45 |
Correct |
49 ms |
424 KB |
Output is correct |
46 |
Correct |
33 ms |
208 KB |
Output is correct |
47 |
Correct |
30 ms |
304 KB |
Output is correct |
48 |
Correct |
29 ms |
420 KB |
Output is correct |