#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 = 472;
map<int, int> occs;
int find_best(int n) {
/* int sum = 0;
int cur = 1;
for (int i = 0; i < 4; ++i) {
sum += cur;
cur = cur * cur + 1;
}
cout << "sum " << sum << endl;*/
int sumMax = -1;
for (int i = 0; i < C; ++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 = C; 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:63:1: warning: control reaches end of non-void function [-Wreturn-type]
63 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
336 KB |
Output is correct |
2 |
Correct |
4 ms |
288 KB |
Output is correct |
3 |
Correct |
8 ms |
288 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
4 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
292 KB |
Output is correct |
8 |
Correct |
4 ms |
288 KB |
Output is correct |
9 |
Correct |
2 ms |
336 KB |
Output is correct |
10 |
Correct |
4 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
288 KB |
Output is correct |
2 |
Correct |
5 ms |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
328 KB |
Output is correct |
4 |
Correct |
3 ms |
336 KB |
Output is correct |
5 |
Correct |
6 ms |
296 KB |
Output is correct |
6 |
Correct |
0 ms |
292 KB |
Output is correct |
7 |
Correct |
5 ms |
280 KB |
Output is correct |
8 |
Correct |
3 ms |
336 KB |
Output is correct |
9 |
Correct |
6 ms |
336 KB |
Output is correct |
10 |
Correct |
5 ms |
336 KB |
Output is correct |
11 |
Correct |
8 ms |
292 KB |
Output is correct |
12 |
Correct |
2 ms |
312 KB |
Output is correct |
13 |
Correct |
10 ms |
336 KB |
Output is correct |
14 |
Correct |
5 ms |
308 KB |
Output is correct |
15 |
Correct |
12 ms |
452 KB |
Output is correct |
16 |
Partially correct |
65 ms |
1052 KB |
Partially correct - number of queries: 7194 |
17 |
Correct |
4 ms |
292 KB |
Output is correct |
18 |
Partially correct |
73 ms |
1144 KB |
Partially correct - number of queries: 8342 |
19 |
Correct |
6 ms |
352 KB |
Output is correct |
20 |
Correct |
25 ms |
548 KB |
Output is correct |
21 |
Correct |
28 ms |
584 KB |
Output is correct |
22 |
Correct |
9 ms |
392 KB |
Output is correct |
23 |
Correct |
6 ms |
336 KB |
Output is correct |
24 |
Correct |
5 ms |
292 KB |
Output is correct |
25 |
Correct |
45 ms |
808 KB |
Output is correct |
26 |
Correct |
43 ms |
796 KB |
Output is correct |
27 |
Correct |
3 ms |
344 KB |
Output is correct |
28 |
Partially correct |
73 ms |
1084 KB |
Partially correct - number of queries: 7877 |
29 |
Partially correct |
85 ms |
884 KB |
Partially correct - number of queries: 6086 |
30 |
Partially correct |
92 ms |
1180 KB |
Partially correct - number of queries: 8297 |
31 |
Correct |
3 ms |
292 KB |
Output is correct |
32 |
Correct |
8 ms |
336 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
28 ms |
564 KB |
Output is correct |
35 |
Correct |
6 ms |
296 KB |
Output is correct |
36 |
Correct |
21 ms |
412 KB |
Output is correct |
37 |
Correct |
7 ms |
296 KB |
Output is correct |
38 |
Correct |
5 ms |
296 KB |
Output is correct |
39 |
Correct |
33 ms |
664 KB |
Output is correct |
40 |
Partially correct |
76 ms |
968 KB |
Partially correct - number of queries: 7197 |
41 |
Partially correct |
59 ms |
748 KB |
Partially correct - number of queries: 5187 |
42 |
Partially correct |
34 ms |
816 KB |
Partially correct - number of queries: 5187 |
43 |
Correct |
45 ms |
720 KB |
Output is correct |
44 |
Correct |
20 ms |
656 KB |
Output is correct |
45 |
Correct |
18 ms |
584 KB |
Output is correct |
46 |
Correct |
6 ms |
280 KB |
Output is correct |
47 |
Correct |
24 ms |
740 KB |
Output is correct |
48 |
Partially correct |
31 ms |
960 KB |
Partially correct - number of queries: 6303 |
49 |
Correct |
9 ms |
348 KB |
Output is correct |
50 |
Partially correct |
93 ms |
1180 KB |
Partially correct - number of queries: 8345 |
51 |
Correct |
36 ms |
676 KB |
Output is correct |
52 |
Correct |
6 ms |
332 KB |
Output is correct |
53 |
Correct |
7 ms |
288 KB |
Output is correct |
54 |
Correct |
39 ms |
688 KB |
Output is correct |
55 |
Correct |
5 ms |
288 KB |
Output is correct |
56 |
Partially correct |
84 ms |
1248 KB |
Partially correct - number of queries: 8346 |
57 |
Partially correct |
65 ms |
928 KB |
Partially correct - number of queries: 6217 |
58 |
Partially correct |
58 ms |
928 KB |
Partially correct - number of queries: 6288 |
59 |
Partially correct |
37 ms |
840 KB |
Partially correct - number of queries: 5182 |
60 |
Correct |
64 ms |
684 KB |
Output is correct |
61 |
Correct |
4 ms |
288 KB |
Output is correct |
62 |
Correct |
4 ms |
296 KB |
Output is correct |
63 |
Correct |
6 ms |
292 KB |
Output is correct |
64 |
Correct |
3 ms |
336 KB |
Output is correct |
65 |
Correct |
6 ms |
284 KB |
Output is correct |
66 |
Correct |
10 ms |
336 KB |
Output is correct |
67 |
Correct |
3 ms |
284 KB |
Output is correct |
68 |
Correct |
6 ms |
296 KB |
Output is correct |
69 |
Correct |
4 ms |
352 KB |
Output is correct |
70 |
Correct |
5 ms |
336 KB |
Output is correct |
71 |
Partially correct |
42 ms |
1180 KB |
Partially correct - number of queries: 8224 |
72 |
Correct |
10 ms |
336 KB |
Output is correct |
73 |
Partially correct |
72 ms |
1076 KB |
Partially correct - number of queries: 8118 |
74 |
Partially correct |
85 ms |
1096 KB |
Partially correct - number of queries: 8176 |
75 |
Correct |
6 ms |
332 KB |
Output is correct |
76 |
Partially correct |
55 ms |
992 KB |
Partially correct - number of queries: 7108 |
77 |
Partially correct |
75 ms |
1096 KB |
Partially correct - number of queries: 8373 |
78 |
Correct |
8 ms |
344 KB |
Output is correct |
79 |
Correct |
38 ms |
800 KB |
Output is correct |
80 |
Partially correct |
83 ms |
1136 KB |
Partially correct - number of queries: 8390 |
81 |
Partially correct |
39 ms |
1168 KB |
Partially correct - number of queries: 8409 |
82 |
Partially correct |
76 ms |
1164 KB |
Partially correct - number of queries: 8308 |
83 |
Correct |
6 ms |
336 KB |
Output is correct |
84 |
Partially correct |
43 ms |
1096 KB |
Partially correct - number of queries: 6918 |
85 |
Partially correct |
68 ms |
1068 KB |
Partially correct - number of queries: 8355 |
86 |
Correct |
5 ms |
336 KB |
Output is correct |
87 |
Correct |
5 ms |
336 KB |
Output is correct |
88 |
Correct |
5 ms |
328 KB |
Output is correct |
89 |
Correct |
4 ms |
336 KB |
Output is correct |
90 |
Correct |
5 ms |
336 KB |
Output is correct |
91 |
Correct |
3 ms |
324 KB |
Output is correct |
92 |
Correct |
5 ms |
288 KB |
Output is correct |
93 |
Correct |
9 ms |
340 KB |
Output is correct |
94 |
Correct |
7 ms |
356 KB |
Output is correct |
95 |
Correct |
8 ms |
312 KB |
Output is correct |
96 |
Correct |
9 ms |
364 KB |
Output is correct |
97 |
Correct |
4 ms |
336 KB |
Output is correct |