#include<bits/stdc++.h>
#include "prize.h"
using namespace std;
int find_best(int n) {
int l, r, mx = -1e9;
for (int i = 0;i < min(10, n);i++){
int ind = rand() % n;
vector<int> res = ask(ind);
if(res[0] + res[1] == 0)
return i;
mx = max(mx , res[0]+res[1]);
}
for(int i = 0; i < n; i++){
vector<int> res = ask(i);
if(res[0] + res[1] == 0)
return i;
mx = max(mx , res[0]+res[1]);
if((res[0]+res[1]) < mx) continue;
l = i + 1;
r = n - 1;
while(l <= r){
int mid = (l+r)/2;
vector<int> tmp=ask(mid);
if(tmp[0]+tmp[1]==0)return mid;
if(tmp == res){
i = mid;
l = mid+1;
}
else r = mid-1;
}
}
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
32 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
372 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
368 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
368 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
7 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
12 ms |
256 KB |
Output is correct |
16 |
Partially correct |
76 ms |
256 KB |
Partially correct - number of queries: 7341 |
17 |
Correct |
1 ms |
400 KB |
Output is correct |
18 |
Partially correct |
82 ms |
256 KB |
Partially correct - number of queries: 8618 |
19 |
Correct |
1 ms |
256 KB |
Output is correct |
20 |
Correct |
31 ms |
256 KB |
Output is correct |
21 |
Correct |
34 ms |
256 KB |
Output is correct |
22 |
Correct |
7 ms |
256 KB |
Output is correct |
23 |
Correct |
1 ms |
256 KB |
Output is correct |
24 |
Correct |
1 ms |
256 KB |
Output is correct |
25 |
Correct |
47 ms |
256 KB |
Output is correct |
26 |
Correct |
44 ms |
256 KB |
Output is correct |
27 |
Correct |
1 ms |
364 KB |
Output is correct |
28 |
Partially correct |
66 ms |
256 KB |
Partially correct - number of queries: 8176 |
29 |
Partially correct |
55 ms |
360 KB |
Partially correct - number of queries: 6211 |
30 |
Partially correct |
65 ms |
256 KB |
Partially correct - number of queries: 8560 |
31 |
Correct |
1 ms |
256 KB |
Output is correct |
32 |
Correct |
4 ms |
256 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
37 ms |
256 KB |
Output is correct |
35 |
Correct |
2 ms |
256 KB |
Output is correct |
36 |
Correct |
20 ms |
256 KB |
Output is correct |
37 |
Correct |
2 ms |
384 KB |
Output is correct |
38 |
Correct |
1 ms |
368 KB |
Output is correct |
39 |
Correct |
50 ms |
256 KB |
Output is correct |
40 |
Partially correct |
93 ms |
256 KB |
Partially correct - number of queries: 7315 |
41 |
Partially correct |
45 ms |
256 KB |
Partially correct - number of queries: 5151 |
42 |
Partially correct |
27 ms |
384 KB |
Partially correct - number of queries: 5151 |
43 |
Correct |
55 ms |
384 KB |
Output is correct |
44 |
Correct |
46 ms |
256 KB |
Output is correct |
45 |
Correct |
26 ms |
256 KB |
Output is correct |
46 |
Correct |
1 ms |
256 KB |
Output is correct |
47 |
Correct |
22 ms |
256 KB |
Output is correct |
48 |
Partially correct |
61 ms |
256 KB |
Partially correct - number of queries: 6373 |
49 |
Correct |
7 ms |
256 KB |
Output is correct |
50 |
Partially correct |
70 ms |
384 KB |
Partially correct - number of queries: 8615 |
51 |
Correct |
44 ms |
256 KB |
Output is correct |
52 |
Correct |
2 ms |
256 KB |
Output is correct |
53 |
Correct |
2 ms |
256 KB |
Output is correct |
54 |
Correct |
41 ms |
256 KB |
Output is correct |
55 |
Correct |
1 ms |
256 KB |
Output is correct |
56 |
Partially correct |
106 ms |
256 KB |
Partially correct - number of queries: 8617 |
57 |
Partially correct |
75 ms |
256 KB |
Partially correct - number of queries: 6297 |
58 |
Partially correct |
62 ms |
256 KB |
Partially correct - number of queries: 6403 |
59 |
Partially correct |
47 ms |
256 KB |
Partially correct - number of queries: 5151 |
60 |
Correct |
45 ms |
256 KB |
Output is correct |
61 |
Correct |
2 ms |
256 KB |
Output is correct |
62 |
Correct |
1 ms |
384 KB |
Output is correct |
63 |
Correct |
3 ms |
256 KB |
Output is correct |
64 |
Correct |
1 ms |
256 KB |
Output is correct |
65 |
Correct |
1 ms |
256 KB |
Output is correct |
66 |
Correct |
6 ms |
256 KB |
Output is correct |
67 |
Correct |
1 ms |
256 KB |
Output is correct |
68 |
Correct |
5 ms |
256 KB |
Output is correct |
69 |
Correct |
7 ms |
256 KB |
Output is correct |
70 |
Correct |
1 ms |
256 KB |
Output is correct |
71 |
Partially correct |
61 ms |
256 KB |
Partially correct - number of queries: 8826 |
72 |
Correct |
7 ms |
256 KB |
Output is correct |
73 |
Partially correct |
80 ms |
256 KB |
Partially correct - number of queries: 8694 |
74 |
Partially correct |
78 ms |
256 KB |
Partially correct - number of queries: 8752 |
75 |
Correct |
2 ms |
256 KB |
Output is correct |
76 |
Partially correct |
71 ms |
256 KB |
Partially correct - number of queries: 7475 |
77 |
Partially correct |
73 ms |
256 KB |
Partially correct - number of queries: 8685 |
78 |
Correct |
7 ms |
256 KB |
Output is correct |
79 |
Correct |
37 ms |
256 KB |
Output is correct |
80 |
Partially correct |
77 ms |
256 KB |
Partially correct - number of queries: 8689 |
81 |
Partially correct |
86 ms |
256 KB |
Partially correct - number of queries: 8676 |
82 |
Partially correct |
95 ms |
256 KB |
Partially correct - number of queries: 8595 |
83 |
Correct |
2 ms |
256 KB |
Output is correct |
84 |
Partially correct |
67 ms |
256 KB |
Partially correct - number of queries: 7054 |
85 |
Partially correct |
56 ms |
256 KB |
Partially correct - number of queries: 8673 |
86 |
Partially correct |
70 ms |
256 KB |
Partially correct - number of queries: 8119 |
87 |
Correct |
6 ms |
256 KB |
Output is correct |
88 |
Partially correct |
61 ms |
256 KB |
Partially correct - number of queries: 7307 |
89 |
Partially correct |
76 ms |
256 KB |
Partially correct - number of queries: 8044 |
90 |
Correct |
2 ms |
256 KB |
Output is correct |
91 |
Correct |
46 ms |
256 KB |
Output is correct |
92 |
Correct |
1 ms |
256 KB |
Output is correct |
93 |
Correct |
7 ms |
256 KB |
Output is correct |
94 |
Correct |
7 ms |
256 KB |
Output is correct |
95 |
Correct |
5 ms |
256 KB |
Output is correct |
96 |
Correct |
6 ms |
256 KB |
Output is correct |
97 |
Correct |
1 ms |
256 KB |
Output is correct |