#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
map<int,pair<int,int>>mp;
int cnta=0;
pair<int,int>pors(int u){
if(mp.count(u)==0){
cnta++;
if(cnta>=10000){
exit(23);
}
vector<int>hey=ask(u);
mp[u]=make_pair(hey[0],hey[1]);
}
return mp[u];
}
int find_best(int n) {
mp.clear();
int cnta=0;
int wtf=-1;
for(int i=0;i<n;){
//cout<<i<<endl;
pair<int,int>av=pors(i);
if(av.first+av.second==0){
return i;
}
cnta++;
pair<int,int>fake;
if(wtf!=-1){
fake=pors(wtf);
if(av.first+av.second<=fake.first+fake.second){
i++;
continue;
}
}
int low=i,high=n,mid,f=0;
for(auto x:mp){
mid=x.first;
fake=pors(mid);
if(fake.first+fake.second!=av.first+av.second){
if(fake.first+fake.second>av.first+av.second){
f=1;
break;
}
high=mid;
}else{
if(fake.first-av.first==0){
low=mid;
}else{
high=mid;
}
}
}
if(f){
wtf=i;
i=low+1;
continue;
}
low=max(low,i);
high=n;
while(high-low>1){
mid=(high+low)>>1;
fake=pors(mid);
if(fake.first+fake.second!=av.first+av.second){
if(fake.first+fake.second>av.first+av.second){
wtf=i;
break;
}
high=mid;
}else{
if(fake.first-av.first==0){
low=mid;
}else{
high=mid;
}
}
}
i=low+1;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
428 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
344 KB |
Output is correct |
15 |
Correct |
11 ms |
344 KB |
Output is correct |
16 |
Partially correct |
151 ms |
588 KB |
Partially correct - number of queries: 6423 |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Partially correct |
214 ms |
828 KB |
Partially correct - number of queries: 7529 |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
15 ms |
592 KB |
Output is correct |
21 |
Correct |
34 ms |
344 KB |
Output is correct |
22 |
Correct |
4 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
73 ms |
736 KB |
Output is correct |
26 |
Correct |
67 ms |
592 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Partially correct |
203 ms |
956 KB |
Partially correct - number of queries: 7236 |
29 |
Partially correct |
109 ms |
852 KB |
Partially correct - number of queries: 5524 |
30 |
Partially correct |
228 ms |
1284 KB |
Partially correct - number of queries: 7450 |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
3 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
344 KB |
Output is correct |
34 |
Correct |
32 ms |
468 KB |
Output is correct |
35 |
Correct |
2 ms |
344 KB |
Output is correct |
36 |
Correct |
14 ms |
344 KB |
Output is correct |
37 |
Correct |
1 ms |
344 KB |
Output is correct |
38 |
Correct |
1 ms |
344 KB |
Output is correct |
39 |
Correct |
46 ms |
552 KB |
Output is correct |
40 |
Partially correct |
173 ms |
592 KB |
Partially correct - number of queries: 6397 |
41 |
Correct |
87 ms |
936 KB |
Output is correct |
42 |
Correct |
78 ms |
592 KB |
Output is correct |
43 |
Correct |
72 ms |
612 KB |
Output is correct |
44 |
Correct |
37 ms |
516 KB |
Output is correct |
45 |
Correct |
29 ms |
1296 KB |
Output is correct |
46 |
Correct |
1 ms |
344 KB |
Output is correct |
47 |
Correct |
49 ms |
848 KB |
Output is correct |
48 |
Partially correct |
124 ms |
568 KB |
Partially correct - number of queries: 5588 |
49 |
Correct |
4 ms |
344 KB |
Output is correct |
50 |
Partially correct |
219 ms |
1040 KB |
Partially correct - number of queries: 7532 |
51 |
Correct |
35 ms |
600 KB |
Output is correct |
52 |
Correct |
1 ms |
344 KB |
Output is correct |
53 |
Correct |
1 ms |
344 KB |
Output is correct |
54 |
Correct |
36 ms |
592 KB |
Output is correct |
55 |
Correct |
0 ms |
340 KB |
Output is correct |
56 |
Partially correct |
211 ms |
732 KB |
Partially correct - number of queries: 7532 |
57 |
Partially correct |
109 ms |
952 KB |
Partially correct - number of queries: 5490 |
58 |
Partially correct |
120 ms |
612 KB |
Partially correct - number of queries: 5582 |
59 |
Correct |
76 ms |
600 KB |
Output is correct |
60 |
Correct |
71 ms |
1108 KB |
Output is correct |
61 |
Correct |
1 ms |
344 KB |
Output is correct |
62 |
Correct |
0 ms |
344 KB |
Output is correct |
63 |
Correct |
1 ms |
344 KB |
Output is correct |
64 |
Correct |
1 ms |
344 KB |
Output is correct |
65 |
Correct |
0 ms |
344 KB |
Output is correct |
66 |
Correct |
2 ms |
344 KB |
Output is correct |
67 |
Correct |
0 ms |
344 KB |
Output is correct |
68 |
Correct |
3 ms |
344 KB |
Output is correct |
69 |
Correct |
2 ms |
344 KB |
Output is correct |
70 |
Correct |
0 ms |
344 KB |
Output is correct |
71 |
Partially correct |
208 ms |
828 KB |
Partially correct - number of queries: 7398 |
72 |
Correct |
3 ms |
344 KB |
Output is correct |
73 |
Partially correct |
205 ms |
852 KB |
Partially correct - number of queries: 7242 |
74 |
Partially correct |
205 ms |
1052 KB |
Partially correct - number of queries: 7313 |
75 |
Correct |
1 ms |
344 KB |
Output is correct |
76 |
Partially correct |
161 ms |
756 KB |
Partially correct - number of queries: 6365 |
77 |
Partially correct |
187 ms |
848 KB |
Partially correct - number of queries: 7519 |
78 |
Correct |
4 ms |
344 KB |
Output is correct |
79 |
Correct |
42 ms |
740 KB |
Output is correct |
80 |
Partially correct |
212 ms |
1104 KB |
Partially correct - number of queries: 7543 |
81 |
Partially correct |
213 ms |
1100 KB |
Partially correct - number of queries: 7487 |
82 |
Partially correct |
206 ms |
860 KB |
Partially correct - number of queries: 7475 |
83 |
Correct |
1 ms |
344 KB |
Output is correct |
84 |
Partially correct |
149 ms |
716 KB |
Partially correct - number of queries: 6195 |
85 |
Partially correct |
205 ms |
796 KB |
Partially correct - number of queries: 7501 |
86 |
Partially correct |
173 ms |
1376 KB |
Partially correct - number of queries: 6419 |
87 |
Correct |
4 ms |
344 KB |
Output is correct |
88 |
Partially correct |
155 ms |
1260 KB |
Partially correct - number of queries: 6076 |
89 |
Partially correct |
170 ms |
960 KB |
Partially correct - number of queries: 6399 |
90 |
Correct |
1 ms |
344 KB |
Output is correct |
91 |
Correct |
53 ms |
592 KB |
Output is correct |
92 |
Correct |
0 ms |
344 KB |
Output is correct |
93 |
Correct |
3 ms |
344 KB |
Output is correct |
94 |
Correct |
3 ms |
600 KB |
Output is correct |
95 |
Correct |
3 ms |
344 KB |
Output is correct |
96 |
Correct |
2 ms |
344 KB |
Output is correct |
97 |
Correct |
0 ms |
344 KB |
Output is correct |