#include<bits/stdc++.h>
#include "prize.h"
//#include "grader.cpp"
using namespace std;
vector<int>GLOB;
int find_best(int n){
int CNT=0;
for(int i=0;i<min(n,500);i++){
vector<int>R=ask(i);
CNT=max(CNT,R[0]+R[1]);
}
int FOUND=0,LAST=0;
while(1){
int L=LAST,R=n-1,mid,BEST=-1;
while(1){
vector<int>z=ask(L);
if(z[0]+z[1]==0)
return L;
if(z[0]+z[1]!=CNT)
L++;
else{
FOUND=z[0];
break;
}
}
while(L<=R){
mid=(L+R)/2;
vector<int>z=ask(mid);
int A=z[0],B=z[1];
if(!A&&!B)
return mid;
else if(A+B!=CNT){
BEST=mid;
R=mid-1;
}
else if(A>FOUND)
R=mid-1;
else
L=mid+1;
}
if(BEST==-1)
exit(1);
LAST=BEST+1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
292 KB |
Output is correct |
2 |
Correct |
4 ms |
268 KB |
Output is correct |
3 |
Correct |
3 ms |
292 KB |
Output is correct |
4 |
Correct |
5 ms |
288 KB |
Output is correct |
5 |
Correct |
3 ms |
288 KB |
Output is correct |
6 |
Correct |
7 ms |
268 KB |
Output is correct |
7 |
Correct |
6 ms |
208 KB |
Output is correct |
8 |
Correct |
3 ms |
300 KB |
Output is correct |
9 |
Correct |
4 ms |
288 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
288 KB |
Output is correct |
2 |
Correct |
6 ms |
292 KB |
Output is correct |
3 |
Correct |
9 ms |
276 KB |
Output is correct |
4 |
Correct |
6 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
292 KB |
Output is correct |
6 |
Correct |
2 ms |
288 KB |
Output is correct |
7 |
Correct |
4 ms |
288 KB |
Output is correct |
8 |
Correct |
5 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
292 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
11 |
Correct |
7 ms |
288 KB |
Output is correct |
12 |
Correct |
3 ms |
208 KB |
Output is correct |
13 |
Correct |
9 ms |
208 KB |
Output is correct |
14 |
Correct |
7 ms |
208 KB |
Output is correct |
15 |
Correct |
14 ms |
292 KB |
Output is correct |
16 |
Partially correct |
74 ms |
208 KB |
Partially correct - number of queries: 7440 |
17 |
Correct |
4 ms |
208 KB |
Output is correct |
18 |
Partially correct |
78 ms |
292 KB |
Partially correct - number of queries: 8637 |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
24 ms |
292 KB |
Output is correct |
21 |
Correct |
32 ms |
292 KB |
Output is correct |
22 |
Correct |
8 ms |
208 KB |
Output is correct |
23 |
Correct |
5 ms |
208 KB |
Output is correct |
24 |
Correct |
6 ms |
208 KB |
Output is correct |
25 |
Partially correct |
38 ms |
208 KB |
Partially correct - number of queries: 5113 |
26 |
Partially correct |
51 ms |
208 KB |
Partially correct - number of queries: 5040 |
27 |
Correct |
3 ms |
268 KB |
Output is correct |
28 |
Partially correct |
62 ms |
292 KB |
Partially correct - number of queries: 8237 |
29 |
Partially correct |
50 ms |
208 KB |
Partially correct - number of queries: 6363 |
30 |
Partially correct |
76 ms |
208 KB |
Partially correct - number of queries: 8568 |
31 |
Correct |
4 ms |
292 KB |
Output is correct |
32 |
Correct |
9 ms |
208 KB |
Output is correct |
33 |
Correct |
1 ms |
208 KB |
Output is correct |
34 |
Correct |
25 ms |
208 KB |
Output is correct |
35 |
Correct |
6 ms |
288 KB |
Output is correct |
36 |
Correct |
25 ms |
208 KB |
Output is correct |
37 |
Correct |
5 ms |
208 KB |
Output is correct |
38 |
Correct |
5 ms |
208 KB |
Output is correct |
39 |
Correct |
22 ms |
208 KB |
Output is correct |
40 |
Partially correct |
74 ms |
208 KB |
Partially correct - number of queries: 7390 |
41 |
Partially correct |
50 ms |
208 KB |
Partially correct - number of queries: 5378 |
42 |
Partially correct |
21 ms |
272 KB |
Partially correct - number of queries: 5378 |
43 |
Correct |
37 ms |
208 KB |
Output is correct |
44 |
Correct |
36 ms |
208 KB |
Output is correct |
45 |
Correct |
13 ms |
300 KB |
Output is correct |
46 |
Correct |
4 ms |
208 KB |
Output is correct |
47 |
Correct |
20 ms |
288 KB |
Output is correct |
48 |
Partially correct |
57 ms |
208 KB |
Partially correct - number of queries: 6525 |
49 |
Correct |
9 ms |
288 KB |
Output is correct |
50 |
Partially correct |
41 ms |
208 KB |
Partially correct - number of queries: 8626 |
51 |
Correct |
34 ms |
208 KB |
Output is correct |
52 |
Correct |
5 ms |
208 KB |
Output is correct |
53 |
Correct |
5 ms |
208 KB |
Output is correct |
54 |
Correct |
45 ms |
272 KB |
Output is correct |
55 |
Correct |
5 ms |
208 KB |
Output is correct |
56 |
Partially correct |
77 ms |
208 KB |
Partially correct - number of queries: 8634 |
57 |
Partially correct |
30 ms |
256 KB |
Partially correct - number of queries: 6441 |
58 |
Partially correct |
49 ms |
208 KB |
Partially correct - number of queries: 6543 |
59 |
Partially correct |
42 ms |
208 KB |
Partially correct - number of queries: 5378 |
60 |
Partially correct |
51 ms |
208 KB |
Partially correct - number of queries: 5024 |
61 |
Correct |
11 ms |
208 KB |
Output is correct |
62 |
Correct |
8 ms |
272 KB |
Output is correct |
63 |
Correct |
6 ms |
208 KB |
Output is correct |
64 |
Correct |
4 ms |
208 KB |
Output is correct |
65 |
Correct |
8 ms |
284 KB |
Output is correct |
66 |
Correct |
10 ms |
208 KB |
Output is correct |
67 |
Correct |
5 ms |
292 KB |
Output is correct |
68 |
Correct |
9 ms |
284 KB |
Output is correct |
69 |
Correct |
7 ms |
208 KB |
Output is correct |
70 |
Correct |
6 ms |
208 KB |
Output is correct |
71 |
Partially correct |
63 ms |
208 KB |
Partially correct - number of queries: 8773 |
72 |
Correct |
11 ms |
208 KB |
Output is correct |
73 |
Partially correct |
54 ms |
208 KB |
Partially correct - number of queries: 8649 |
74 |
Partially correct |
69 ms |
208 KB |
Partially correct - number of queries: 8724 |
75 |
Correct |
7 ms |
208 KB |
Output is correct |
76 |
Partially correct |
76 ms |
208 KB |
Partially correct - number of queries: 7541 |
77 |
Partially correct |
63 ms |
208 KB |
Partially correct - number of queries: 7236 |
78 |
Correct |
7 ms |
208 KB |
Output is correct |
79 |
Correct |
55 ms |
208 KB |
Output is correct |
80 |
Partially correct |
41 ms |
292 KB |
Partially correct - number of queries: 8652 |
81 |
Partially correct |
43 ms |
208 KB |
Partially correct - number of queries: 8620 |
82 |
Partially correct |
99 ms |
208 KB |
Partially correct - number of queries: 8592 |
83 |
Correct |
6 ms |
208 KB |
Output is correct |
84 |
Partially correct |
78 ms |
208 KB |
Partially correct - number of queries: 7169 |
85 |
Partially correct |
58 ms |
292 KB |
Partially correct - number of queries: 8678 |
86 |
Correct |
9 ms |
208 KB |
Output is correct |
87 |
Correct |
8 ms |
228 KB |
Output is correct |
88 |
Correct |
7 ms |
288 KB |
Output is correct |
89 |
Correct |
12 ms |
292 KB |
Output is correct |
90 |
Correct |
5 ms |
208 KB |
Output is correct |
91 |
Correct |
7 ms |
208 KB |
Output is correct |
92 |
Correct |
9 ms |
208 KB |
Output is correct |
93 |
Correct |
14 ms |
208 KB |
Output is correct |
94 |
Correct |
24 ms |
208 KB |
Output is correct |
95 |
Correct |
7 ms |
208 KB |
Output is correct |
96 |
Correct |
7 ms |
208 KB |
Output is correct |
97 |
Correct |
8 ms |
208 KB |
Output is correct |