#include <bits/stdc++.h>
#include "prize.h"
#define vc vector
using namespace std;
int find_best(int n){
map<int, map<int, int>> pod;
function<int (int, int)> solve=[&](int l, int r){
if(l>r) return -1;
int mid=(l+r)/2;
for(auto v: pod){
int kokvseh=v.first;
int kokprej=-1, kokpol=-1;
auto pol = v.second.upper_bound( mid);
if(pol!=v.second.end()) kokpol=(pol->second);
if(pol!=v.second.begin()) {auto prej = pol;--prej; kokprej=(prej->second);}
if(kokpol==0) return -1;
if(kokprej==kokvseh) return -1;
if(kokpol==kokprej) return -1;
}
vc<int> q=ask(mid);
if(q[0]+q[1]==0) return mid;
pod[q[0]+q[1]][mid]=q[0];
return max(solve(l, mid-1), solve(mid+1, r));
};
return solve(0, n-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
268 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
288 KB |
Output is correct |
8 |
Correct |
1 ms |
292 KB |
Output is correct |
9 |
Correct |
0 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
208 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 |
1 ms |
284 KB |
Output is correct |
4 |
Correct |
0 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
10 ms |
284 KB |
Output is correct |
12 |
Correct |
9 ms |
320 KB |
Output is correct |
13 |
Correct |
7 ms |
208 KB |
Output is correct |
14 |
Correct |
33 ms |
328 KB |
Output is correct |
15 |
Correct |
561 ms |
712 KB |
Output is correct |
16 |
Correct |
42 ms |
280 KB |
Output is correct |
17 |
Correct |
836 ms |
844 KB |
Output is correct |
18 |
Correct |
80 ms |
328 KB |
Output is correct |
19 |
Correct |
743 ms |
852 KB |
Output is correct |
20 |
Correct |
218 ms |
496 KB |
Output is correct |
21 |
Correct |
397 ms |
600 KB |
Output is correct |
22 |
Correct |
412 ms |
528 KB |
Output is correct |
23 |
Correct |
2 ms |
208 KB |
Output is correct |
24 |
Correct |
10 ms |
284 KB |
Output is correct |
25 |
Correct |
152 ms |
420 KB |
Output is correct |
26 |
Correct |
560 ms |
588 KB |
Output is correct |
27 |
Correct |
2 ms |
284 KB |
Output is correct |
28 |
Correct |
5 ms |
272 KB |
Output is correct |
29 |
Correct |
12 ms |
316 KB |
Output is correct |
30 |
Correct |
2 ms |
284 KB |
Output is correct |
31 |
Correct |
871 ms |
900 KB |
Output is correct |
32 |
Correct |
7 ms |
208 KB |
Output is correct |
33 |
Correct |
1 ms |
208 KB |
Output is correct |
34 |
Correct |
736 ms |
728 KB |
Output is correct |
35 |
Correct |
2 ms |
284 KB |
Output is correct |
36 |
Correct |
569 ms |
700 KB |
Output is correct |
37 |
Correct |
10 ms |
284 KB |
Output is correct |
38 |
Correct |
2 ms |
292 KB |
Output is correct |
39 |
Correct |
310 ms |
524 KB |
Output is correct |
40 |
Correct |
259 ms |
504 KB |
Output is correct |
41 |
Correct |
329 ms |
484 KB |
Output is correct |
42 |
Correct |
383 ms |
640 KB |
Output is correct |
43 |
Correct |
358 ms |
760 KB |
Output is correct |
44 |
Correct |
669 ms |
696 KB |
Output is correct |
45 |
Correct |
716 ms |
732 KB |
Output is correct |
46 |
Correct |
909 ms |
688 KB |
Output is correct |
47 |
Correct |
692 ms |
668 KB |
Output is correct |
48 |
Correct |
151 ms |
556 KB |
Output is correct |
49 |
Correct |
791 ms |
760 KB |
Output is correct |
50 |
Correct |
68 ms |
288 KB |
Output is correct |
51 |
Correct |
572 ms |
756 KB |
Output is correct |
52 |
Correct |
860 ms |
624 KB |
Output is correct |
53 |
Correct |
2 ms |
284 KB |
Output is correct |
54 |
Correct |
380 ms |
628 KB |
Output is correct |
55 |
Correct |
836 ms |
812 KB |
Output is correct |
56 |
Correct |
7 ms |
304 KB |
Output is correct |
57 |
Correct |
61 ms |
384 KB |
Output is correct |
58 |
Correct |
479 ms |
700 KB |
Output is correct |
59 |
Correct |
297 ms |
640 KB |
Output is correct |
60 |
Correct |
230 ms |
604 KB |
Output is correct |
61 |
Correct |
1 ms |
288 KB |
Output is correct |
62 |
Correct |
4 ms |
280 KB |
Output is correct |
63 |
Correct |
1 ms |
208 KB |
Output is correct |
64 |
Correct |
2 ms |
272 KB |
Output is correct |
65 |
Correct |
1 ms |
256 KB |
Output is correct |
66 |
Correct |
1 ms |
208 KB |
Output is correct |
67 |
Correct |
1 ms |
288 KB |
Output is correct |
68 |
Correct |
1 ms |
288 KB |
Output is correct |
69 |
Correct |
1 ms |
268 KB |
Output is correct |
70 |
Correct |
2 ms |
272 KB |
Output is correct |
71 |
Correct |
923 ms |
668 KB |
Output is correct |
72 |
Correct |
13 ms |
324 KB |
Output is correct |
73 |
Correct |
941 ms |
772 KB |
Output is correct |
74 |
Correct |
989 ms |
844 KB |
Output is correct |
75 |
Correct |
2 ms |
256 KB |
Output is correct |
76 |
Correct |
632 ms |
728 KB |
Output is correct |
77 |
Correct |
893 ms |
784 KB |
Output is correct |
78 |
Correct |
13 ms |
336 KB |
Output is correct |
79 |
Correct |
220 ms |
428 KB |
Output is correct |
80 |
Correct |
845 ms |
760 KB |
Output is correct |
81 |
Correct |
896 ms |
772 KB |
Output is correct |
82 |
Correct |
908 ms |
728 KB |
Output is correct |
83 |
Correct |
3 ms |
208 KB |
Output is correct |
84 |
Correct |
643 ms |
632 KB |
Output is correct |
85 |
Correct |
877 ms |
784 KB |
Output is correct |
86 |
Correct |
13 ms |
312 KB |
Output is correct |
87 |
Correct |
4 ms |
208 KB |
Output is correct |
88 |
Correct |
14 ms |
304 KB |
Output is correct |
89 |
Correct |
12 ms |
208 KB |
Output is correct |
90 |
Correct |
3 ms |
208 KB |
Output is correct |
91 |
Correct |
9 ms |
316 KB |
Output is correct |
92 |
Correct |
1 ms |
208 KB |
Output is correct |
93 |
Correct |
9 ms |
208 KB |
Output is correct |
94 |
Correct |
8 ms |
324 KB |
Output is correct |
95 |
Correct |
10 ms |
208 KB |
Output is correct |
96 |
Correct |
6 ms |
208 KB |
Output is correct |
97 |
Correct |
1 ms |
208 KB |
Output is correct |