#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> cache[200005];
vector<int> myask(int x){
if(cache[x].empty())cache[x]=ask(x);
return cache[x];
}
int find_best(int n) {
int Maxnum=0;
for(int i = 0;i<n&&i<500;i++){
vector<int> v=myask(i);
if(v[0]+v[1]==0)return i;
Maxnum=max(Maxnum,v[0]+v[1]);
}
int l=0,r=n-1;
int num=0;
while(true){
int Max=r,Min=l;
// printf("%d %d\n",Max,Min);
while(Max>Min){
int mid=(Max+Min)/2;
vector<int> v=myask(mid);
if(v[0]+v[1]==0)return mid;
if(v[0]+v[1]!=Maxnum){
Max=mid;
}
else{
if(v[0]-num)Max=mid-1;
else Min=mid+1;
}
}
num++;
vector<int> v=myask(Max);
if(v[0]+v[1]==0)return Max;
// printf("? %d %d %d\n",v[0],v[1],num);
l=Min+1;
}
/*
int Max=n-1,Min=0;
while(Max>Min){
int mid=(Max+Min)/2;
vector<int> v=ask(mid);
if(v[0]+v[1]==0){
return mid;
}
if(v[0]<v[1]){
Min=mid+1;
}
else{
Max=mid-1;
}
}
return Min;*/
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
5024 KB |
Output is correct |
2 |
Correct |
11 ms |
5084 KB |
Output is correct |
3 |
Correct |
9 ms |
5060 KB |
Output is correct |
4 |
Correct |
11 ms |
5108 KB |
Output is correct |
5 |
Correct |
9 ms |
5056 KB |
Output is correct |
6 |
Correct |
4 ms |
5056 KB |
Output is correct |
7 |
Correct |
10 ms |
5056 KB |
Output is correct |
8 |
Correct |
10 ms |
5188 KB |
Output is correct |
9 |
Correct |
9 ms |
4992 KB |
Output is correct |
10 |
Correct |
11 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
4992 KB |
Output is correct |
2 |
Correct |
8 ms |
4992 KB |
Output is correct |
3 |
Correct |
8 ms |
4992 KB |
Output is correct |
4 |
Correct |
9 ms |
4992 KB |
Output is correct |
5 |
Correct |
11 ms |
5072 KB |
Output is correct |
6 |
Correct |
3 ms |
4992 KB |
Output is correct |
7 |
Correct |
9 ms |
4992 KB |
Output is correct |
8 |
Correct |
9 ms |
4992 KB |
Output is correct |
9 |
Correct |
11 ms |
4992 KB |
Output is correct |
10 |
Correct |
8 ms |
4992 KB |
Output is correct |
11 |
Correct |
11 ms |
4992 KB |
Output is correct |
12 |
Correct |
10 ms |
4992 KB |
Output is correct |
13 |
Correct |
15 ms |
5084 KB |
Output is correct |
14 |
Correct |
9 ms |
4992 KB |
Output is correct |
15 |
Correct |
23 ms |
5112 KB |
Output is correct |
16 |
Partially correct |
67 ms |
5240 KB |
Partially correct - number of queries: 6922 |
17 |
Correct |
9 ms |
4992 KB |
Output is correct |
18 |
Partially correct |
98 ms |
5240 KB |
Partially correct - number of queries: 8011 |
19 |
Correct |
11 ms |
4992 KB |
Output is correct |
20 |
Correct |
35 ms |
5112 KB |
Output is correct |
21 |
Correct |
35 ms |
5112 KB |
Output is correct |
22 |
Correct |
14 ms |
4992 KB |
Output is correct |
23 |
Correct |
10 ms |
4992 KB |
Output is correct |
24 |
Correct |
10 ms |
4992 KB |
Output is correct |
25 |
Correct |
65 ms |
5188 KB |
Output is correct |
26 |
Correct |
61 ms |
5112 KB |
Output is correct |
27 |
Correct |
7 ms |
5060 KB |
Output is correct |
28 |
Partially correct |
81 ms |
5240 KB |
Partially correct - number of queries: 7606 |
29 |
Partially correct |
63 ms |
5240 KB |
Partially correct - number of queries: 5882 |
30 |
Partially correct |
79 ms |
5244 KB |
Partially correct - number of queries: 7952 |
31 |
Correct |
9 ms |
5060 KB |
Output is correct |
32 |
Correct |
10 ms |
4992 KB |
Output is correct |
33 |
Correct |
4 ms |
4992 KB |
Output is correct |
34 |
Correct |
28 ms |
5112 KB |
Output is correct |
35 |
Correct |
10 ms |
4992 KB |
Output is correct |
36 |
Correct |
31 ms |
5024 KB |
Output is correct |
37 |
Correct |
9 ms |
4992 KB |
Output is correct |
38 |
Correct |
10 ms |
4992 KB |
Output is correct |
39 |
Correct |
54 ms |
5112 KB |
Output is correct |
40 |
Partially correct |
85 ms |
5240 KB |
Partially correct - number of queries: 6881 |
41 |
Partially correct |
68 ms |
5112 KB |
Partially correct - number of queries: 5019 |
42 |
Partially correct |
69 ms |
5200 KB |
Partially correct - number of queries: 5019 |
43 |
Correct |
45 ms |
5216 KB |
Output is correct |
44 |
Correct |
46 ms |
5112 KB |
Output is correct |
45 |
Correct |
33 ms |
5112 KB |
Output is correct |
46 |
Correct |
8 ms |
4992 KB |
Output is correct |
47 |
Correct |
40 ms |
5112 KB |
Output is correct |
48 |
Partially correct |
75 ms |
5240 KB |
Partially correct - number of queries: 6080 |
49 |
Correct |
14 ms |
5104 KB |
Output is correct |
50 |
Partially correct |
80 ms |
5240 KB |
Partially correct - number of queries: 8008 |
51 |
Correct |
44 ms |
5112 KB |
Output is correct |
52 |
Correct |
11 ms |
4992 KB |
Output is correct |
53 |
Correct |
11 ms |
5084 KB |
Output is correct |
54 |
Correct |
40 ms |
5112 KB |
Output is correct |
55 |
Correct |
8 ms |
4992 KB |
Output is correct |
56 |
Partially correct |
72 ms |
5240 KB |
Partially correct - number of queries: 8010 |
57 |
Partially correct |
60 ms |
5240 KB |
Partially correct - number of queries: 5986 |
58 |
Partially correct |
52 ms |
5240 KB |
Partially correct - number of queries: 6055 |
59 |
Partially correct |
51 ms |
5112 KB |
Partially correct - number of queries: 5015 |
60 |
Correct |
36 ms |
5112 KB |
Output is correct |
61 |
Correct |
10 ms |
4992 KB |
Output is correct |
62 |
Correct |
9 ms |
4992 KB |
Output is correct |
63 |
Correct |
9 ms |
4992 KB |
Output is correct |
64 |
Correct |
9 ms |
4992 KB |
Output is correct |
65 |
Correct |
12 ms |
5068 KB |
Output is correct |
66 |
Correct |
12 ms |
4992 KB |
Output is correct |
67 |
Correct |
8 ms |
4992 KB |
Output is correct |
68 |
Correct |
7 ms |
5060 KB |
Output is correct |
69 |
Correct |
13 ms |
4992 KB |
Output is correct |
70 |
Correct |
6 ms |
5116 KB |
Output is correct |
71 |
Partially correct |
83 ms |
5220 KB |
Partially correct - number of queries: 8270 |
72 |
Correct |
12 ms |
4992 KB |
Output is correct |
73 |
Partially correct |
90 ms |
5240 KB |
Partially correct - number of queries: 8159 |
74 |
Partially correct |
75 ms |
5240 KB |
Partially correct - number of queries: 8219 |
75 |
Correct |
12 ms |
4992 KB |
Output is correct |
76 |
Partially correct |
82 ms |
5224 KB |
Partially correct - number of queries: 7113 |
77 |
Partially correct |
67 ms |
5240 KB |
Partially correct - number of queries: 8007 |
78 |
Correct |
13 ms |
5072 KB |
Output is correct |
79 |
Correct |
37 ms |
5200 KB |
Output is correct |
80 |
Partially correct |
98 ms |
5328 KB |
Partially correct - number of queries: 8016 |
81 |
Partially correct |
87 ms |
5380 KB |
Partially correct - number of queries: 7989 |
82 |
Partially correct |
96 ms |
5268 KB |
Partially correct - number of queries: 7918 |
83 |
Correct |
9 ms |
4992 KB |
Output is correct |
84 |
Partially correct |
70 ms |
5160 KB |
Partially correct - number of queries: 6643 |
85 |
Partially correct |
48 ms |
5188 KB |
Partially correct - number of queries: 8045 |
86 |
Correct |
59 ms |
5112 KB |
Output is correct |
87 |
Correct |
12 ms |
5080 KB |
Output is correct |
88 |
Correct |
51 ms |
5356 KB |
Output is correct |
89 |
Correct |
44 ms |
5080 KB |
Output is correct |
90 |
Correct |
10 ms |
4992 KB |
Output is correct |
91 |
Correct |
29 ms |
5076 KB |
Output is correct |
92 |
Correct |
53 ms |
5124 KB |
Output is correct |
93 |
Correct |
49 ms |
5244 KB |
Output is correct |
94 |
Correct |
50 ms |
5196 KB |
Output is correct |
95 |
Correct |
57 ms |
5112 KB |
Output is correct |
96 |
Correct |
56 ms |
5088 KB |
Output is correct |
97 |
Correct |
40 ms |
5288 KB |
Output is correct |