#include "prize.h"
#include <bits/stdc++.h>
#define chmin(x, v) x = min(x, v)
using namespace std;
map<int, vector<int>> ans;
vector<int> ask_res(int i){
if (ans.count(i)) return ans[i];
ans[i] = ask(i);
//if (i != 7) cout << "query " << i << " " << rep[0] << " " << rep[1] << endl;
return ans[i];
}
const int C = 6;
map<int, int> occs;
int find_best(int n) {
int sumMax = -1;
for (int i = 0; i < 500; ++i){
vector<int> ans = ask_res(i);
occs[ans[0] + ans[1]]++;
if (ans[0] + ans[1] == 0) return i;
if (ans[0] + ans[1] > sumMax)
sumMax = ans[0] + ans[1];
}
for (int i = 500; i < n; ++i){
vector<int> ans = ask_res(i);
if (ans[0] + ans[1] == 0) return i;
if (ans[0] + ans[1] != sumMax)
continue;
int pasBonbons = ans[0];
int deb = i + 1, fin = n, saut = n - 1;
while (fin >= deb){
int mid = (deb + fin)/2;
vector<int> cur = ask_res(mid);
if (cur[0] + cur[1] == 0) return mid;
if (cur[0] + cur[1] != sumMax){
fin = mid - 1;
chmin(saut, mid);
continue;
}
if (cur[0] != pasBonbons) {
fin = mid - 1;
chmin(saut, mid);
}
else
deb = mid + 1;
}
//on a le prochain pas bonbon
i = saut;
}
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:56:1: warning: control reaches end of non-void function [-Wreturn-type]
56 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
320 KB |
Output is correct |
2 |
Correct |
9 ms |
280 KB |
Output is correct |
3 |
Correct |
5 ms |
284 KB |
Output is correct |
4 |
Correct |
5 ms |
292 KB |
Output is correct |
5 |
Correct |
3 ms |
316 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
6 ms |
336 KB |
Output is correct |
8 |
Correct |
7 ms |
284 KB |
Output is correct |
9 |
Correct |
6 ms |
288 KB |
Output is correct |
10 |
Correct |
7 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
292 KB |
Output is correct |
2 |
Correct |
6 ms |
328 KB |
Output is correct |
3 |
Correct |
7 ms |
288 KB |
Output is correct |
4 |
Correct |
4 ms |
324 KB |
Output is correct |
5 |
Correct |
5 ms |
292 KB |
Output is correct |
6 |
Correct |
0 ms |
288 KB |
Output is correct |
7 |
Correct |
2 ms |
316 KB |
Output is correct |
8 |
Correct |
5 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
336 KB |
Output is correct |
10 |
Correct |
6 ms |
336 KB |
Output is correct |
11 |
Correct |
7 ms |
292 KB |
Output is correct |
12 |
Correct |
6 ms |
328 KB |
Output is correct |
13 |
Correct |
10 ms |
328 KB |
Output is correct |
14 |
Correct |
6 ms |
336 KB |
Output is correct |
15 |
Correct |
8 ms |
448 KB |
Output is correct |
16 |
Partially correct |
89 ms |
1060 KB |
Partially correct - number of queries: 7223 |
17 |
Correct |
5 ms |
280 KB |
Output is correct |
18 |
Partially correct |
38 ms |
1180 KB |
Partially correct - number of queries: 8371 |
19 |
Correct |
4 ms |
276 KB |
Output is correct |
20 |
Correct |
23 ms |
520 KB |
Output is correct |
21 |
Correct |
31 ms |
540 KB |
Output is correct |
22 |
Correct |
13 ms |
348 KB |
Output is correct |
23 |
Correct |
3 ms |
316 KB |
Output is correct |
24 |
Correct |
3 ms |
304 KB |
Output is correct |
25 |
Correct |
41 ms |
808 KB |
Output is correct |
26 |
Correct |
37 ms |
720 KB |
Output is correct |
27 |
Correct |
5 ms |
320 KB |
Output is correct |
28 |
Partially correct |
97 ms |
1104 KB |
Partially correct - number of queries: 7908 |
29 |
Partially correct |
27 ms |
928 KB |
Partially correct - number of queries: 6114 |
30 |
Partially correct |
95 ms |
1204 KB |
Partially correct - number of queries: 8323 |
31 |
Correct |
4 ms |
208 KB |
Output is correct |
32 |
Correct |
10 ms |
268 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
14 ms |
600 KB |
Output is correct |
35 |
Correct |
8 ms |
268 KB |
Output is correct |
36 |
Correct |
12 ms |
520 KB |
Output is correct |
37 |
Correct |
10 ms |
336 KB |
Output is correct |
38 |
Correct |
5 ms |
320 KB |
Output is correct |
39 |
Correct |
34 ms |
668 KB |
Output is correct |
40 |
Partially correct |
64 ms |
1012 KB |
Partially correct - number of queries: 7208 |
41 |
Partially correct |
53 ms |
760 KB |
Partially correct - number of queries: 5213 |
42 |
Partially correct |
60 ms |
808 KB |
Partially correct - number of queries: 5213 |
43 |
Correct |
36 ms |
712 KB |
Output is correct |
44 |
Correct |
28 ms |
604 KB |
Output is correct |
45 |
Correct |
14 ms |
588 KB |
Output is correct |
46 |
Correct |
8 ms |
464 KB |
Output is correct |
47 |
Correct |
22 ms |
736 KB |
Output is correct |
48 |
Partially correct |
49 ms |
920 KB |
Partially correct - number of queries: 6332 |
49 |
Correct |
7 ms |
420 KB |
Output is correct |
50 |
Partially correct |
70 ms |
1216 KB |
Partially correct - number of queries: 8374 |
51 |
Correct |
27 ms |
616 KB |
Output is correct |
52 |
Correct |
7 ms |
332 KB |
Output is correct |
53 |
Correct |
6 ms |
308 KB |
Output is correct |
54 |
Correct |
28 ms |
680 KB |
Output is correct |
55 |
Correct |
5 ms |
412 KB |
Output is correct |
56 |
Partially correct |
38 ms |
1192 KB |
Partially correct - number of queries: 8375 |
57 |
Partially correct |
62 ms |
852 KB |
Partially correct - number of queries: 6245 |
58 |
Partially correct |
52 ms |
936 KB |
Partially correct - number of queries: 6316 |
59 |
Partially correct |
40 ms |
808 KB |
Partially correct - number of queries: 5208 |
60 |
Correct |
43 ms |
760 KB |
Output is correct |
61 |
Correct |
7 ms |
336 KB |
Output is correct |
62 |
Correct |
5 ms |
336 KB |
Output is correct |
63 |
Correct |
7 ms |
296 KB |
Output is correct |
64 |
Correct |
3 ms |
324 KB |
Output is correct |
65 |
Correct |
4 ms |
324 KB |
Output is correct |
66 |
Correct |
9 ms |
408 KB |
Output is correct |
67 |
Correct |
4 ms |
292 KB |
Output is correct |
68 |
Correct |
5 ms |
288 KB |
Output is correct |
69 |
Correct |
11 ms |
340 KB |
Output is correct |
70 |
Correct |
5 ms |
440 KB |
Output is correct |
71 |
Partially correct |
74 ms |
1192 KB |
Partially correct - number of queries: 8274 |
72 |
Correct |
9 ms |
392 KB |
Output is correct |
73 |
Partially correct |
85 ms |
1068 KB |
Partially correct - number of queries: 8158 |
74 |
Partially correct |
79 ms |
1108 KB |
Partially correct - number of queries: 8201 |
75 |
Correct |
10 ms |
356 KB |
Output is correct |
76 |
Partially correct |
35 ms |
1056 KB |
Partially correct - number of queries: 7142 |
77 |
Partially correct |
64 ms |
1092 KB |
Partially correct - number of queries: 8411 |
78 |
Correct |
5 ms |
296 KB |
Output is correct |
79 |
Correct |
51 ms |
680 KB |
Output is correct |
80 |
Partially correct |
39 ms |
1132 KB |
Partially correct - number of queries: 8429 |
81 |
Partially correct |
57 ms |
1208 KB |
Partially correct - number of queries: 8412 |
82 |
Partially correct |
64 ms |
1200 KB |
Partially correct - number of queries: 8319 |
83 |
Correct |
7 ms |
356 KB |
Output is correct |
84 |
Partially correct |
56 ms |
1116 KB |
Partially correct - number of queries: 6924 |
85 |
Partially correct |
89 ms |
1200 KB |
Partially correct - number of queries: 8414 |
86 |
Correct |
6 ms |
332 KB |
Output is correct |
87 |
Correct |
6 ms |
336 KB |
Output is correct |
88 |
Correct |
5 ms |
336 KB |
Output is correct |
89 |
Correct |
5 ms |
336 KB |
Output is correct |
90 |
Correct |
6 ms |
336 KB |
Output is correct |
91 |
Correct |
6 ms |
336 KB |
Output is correct |
92 |
Correct |
6 ms |
308 KB |
Output is correct |
93 |
Correct |
9 ms |
368 KB |
Output is correct |
94 |
Correct |
4 ms |
372 KB |
Output is correct |
95 |
Correct |
13 ms |
344 KB |
Output is correct |
96 |
Correct |
9 ms |
356 KB |
Output is correct |
97 |
Correct |
7 ms |
360 KB |
Output is correct |