#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
int sqrtn = 500;
int find_best(int n) {
sqrtn = min(sqrtn, n);
int max_sum = 0;
for (int i = 0; i < sqrtn; i++)
{
auto a = ask(i);
max_sum = max(max_sum, a[0] + a[1]);
if (a[0] + a[1] == 0) {
return i;
}
}
for (int i = sqrtn; i < n; i++) {
auto val = ask(i);
if (val[0] + val[1] != max_sum) {
if (val[0] + val[1] == 0)
return i;
continue;
}
int rval = val[1];
int l = i, r = n - 1, ans = -1;
while (l < r) {
int mid = (l + r) / 2;
auto midval = ask(mid);
if (midval[0] + midval[1] != max_sum || midval[1] < rval)
r = mid;
else
l = mid + 1, ans = mid;
}
i = ans;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
288 KB |
Output is correct |
2 |
Correct |
3 ms |
292 KB |
Output is correct |
3 |
Correct |
3 ms |
288 KB |
Output is correct |
4 |
Correct |
2 ms |
292 KB |
Output is correct |
5 |
Correct |
4 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
288 KB |
Output is correct |
7 |
Correct |
2 ms |
292 KB |
Output is correct |
8 |
Correct |
3 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
208 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
296 KB |
Output is correct |
2 |
Correct |
2 ms |
288 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
5 ms |
288 KB |
Output is correct |
5 |
Correct |
4 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
3 ms |
292 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
292 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
11 |
Correct |
3 ms |
300 KB |
Output is correct |
12 |
Correct |
2 ms |
292 KB |
Output is correct |
13 |
Correct |
4 ms |
292 KB |
Output is correct |
14 |
Correct |
4 ms |
208 KB |
Output is correct |
15 |
Correct |
7 ms |
292 KB |
Output is correct |
16 |
Partially correct |
54 ms |
208 KB |
Partially correct - number of queries: 7826 |
17 |
Correct |
5 ms |
296 KB |
Output is correct |
18 |
Partially correct |
73 ms |
208 KB |
Partially correct - number of queries: 9112 |
19 |
Correct |
2 ms |
276 KB |
Output is correct |
20 |
Correct |
20 ms |
288 KB |
Output is correct |
21 |
Correct |
30 ms |
288 KB |
Output is correct |
22 |
Correct |
10 ms |
288 KB |
Output is correct |
23 |
Correct |
4 ms |
296 KB |
Output is correct |
24 |
Correct |
2 ms |
296 KB |
Output is correct |
25 |
Partially correct |
22 ms |
280 KB |
Partially correct - number of queries: 5334 |
26 |
Partially correct |
43 ms |
208 KB |
Partially correct - number of queries: 5274 |
27 |
Correct |
5 ms |
208 KB |
Output is correct |
28 |
Partially correct |
68 ms |
208 KB |
Partially correct - number of queries: 8664 |
29 |
Partially correct |
39 ms |
288 KB |
Partially correct - number of queries: 6673 |
30 |
Partially correct |
66 ms |
208 KB |
Partially correct - number of queries: 9019 |
31 |
Correct |
2 ms |
208 KB |
Output is correct |
32 |
Correct |
4 ms |
288 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
29 ms |
208 KB |
Output is correct |
35 |
Correct |
6 ms |
288 KB |
Output is correct |
36 |
Correct |
20 ms |
208 KB |
Output is correct |
37 |
Correct |
7 ms |
208 KB |
Output is correct |
38 |
Correct |
5 ms |
208 KB |
Output is correct |
39 |
Correct |
37 ms |
288 KB |
Output is correct |
40 |
Partially correct |
50 ms |
296 KB |
Partially correct - number of queries: 7781 |
41 |
Partially correct |
18 ms |
288 KB |
Partially correct - number of queries: 5625 |
42 |
Partially correct |
38 ms |
208 KB |
Partially correct - number of queries: 5625 |
43 |
Partially correct |
43 ms |
292 KB |
Partially correct - number of queries: 5129 |
44 |
Correct |
19 ms |
276 KB |
Output is correct |
45 |
Correct |
12 ms |
288 KB |
Output is correct |
46 |
Correct |
2 ms |
328 KB |
Output is correct |
47 |
Correct |
15 ms |
292 KB |
Output is correct |
48 |
Partially correct |
23 ms |
328 KB |
Partially correct - number of queries: 6846 |
49 |
Correct |
11 ms |
292 KB |
Output is correct |
50 |
Partially correct |
72 ms |
208 KB |
Partially correct - number of queries: 9107 |
51 |
Correct |
14 ms |
292 KB |
Output is correct |
52 |
Correct |
2 ms |
296 KB |
Output is correct |
53 |
Correct |
2 ms |
336 KB |
Output is correct |
54 |
Correct |
32 ms |
292 KB |
Output is correct |
55 |
Correct |
2 ms |
288 KB |
Output is correct |
56 |
Partially correct |
57 ms |
256 KB |
Partially correct - number of queries: 9094 |
57 |
Partially correct |
33 ms |
292 KB |
Partially correct - number of queries: 6751 |
58 |
Partially correct |
59 ms |
208 KB |
Partially correct - number of queries: 6870 |
59 |
Partially correct |
30 ms |
208 KB |
Partially correct - number of queries: 5625 |
60 |
Partially correct |
47 ms |
208 KB |
Partially correct - number of queries: 5259 |
61 |
Correct |
6 ms |
208 KB |
Output is correct |
62 |
Correct |
4 ms |
288 KB |
Output is correct |
63 |
Correct |
6 ms |
208 KB |
Output is correct |
64 |
Correct |
3 ms |
296 KB |
Output is correct |
65 |
Correct |
5 ms |
292 KB |
Output is correct |
66 |
Correct |
6 ms |
208 KB |
Output is correct |
67 |
Correct |
5 ms |
208 KB |
Output is correct |
68 |
Correct |
4 ms |
208 KB |
Output is correct |
69 |
Correct |
6 ms |
288 KB |
Output is correct |
70 |
Correct |
5 ms |
268 KB |
Output is correct |
71 |
Partially correct |
67 ms |
288 KB |
Partially correct - number of queries: 9286 |
72 |
Correct |
6 ms |
208 KB |
Output is correct |
73 |
Partially correct |
76 ms |
208 KB |
Partially correct - number of queries: 9167 |
74 |
Partially correct |
50 ms |
208 KB |
Partially correct - number of queries: 9214 |
75 |
Correct |
5 ms |
208 KB |
Output is correct |
76 |
Partially correct |
64 ms |
208 KB |
Partially correct - number of queries: 7960 |
77 |
Partially correct |
76 ms |
208 KB |
Partially correct - number of queries: 9163 |
78 |
Correct |
7 ms |
292 KB |
Output is correct |
79 |
Correct |
36 ms |
208 KB |
Output is correct |
80 |
Partially correct |
85 ms |
208 KB |
Partially correct - number of queries: 9147 |
81 |
Partially correct |
66 ms |
208 KB |
Partially correct - number of queries: 9140 |
82 |
Partially correct |
59 ms |
292 KB |
Partially correct - number of queries: 9005 |
83 |
Correct |
3 ms |
208 KB |
Output is correct |
84 |
Partially correct |
65 ms |
292 KB |
Partially correct - number of queries: 7527 |
85 |
Partially correct |
82 ms |
256 KB |
Partially correct - number of queries: 9097 |
86 |
Correct |
5 ms |
208 KB |
Output is correct |
87 |
Correct |
5 ms |
208 KB |
Output is correct |
88 |
Correct |
3 ms |
288 KB |
Output is correct |
89 |
Correct |
5 ms |
208 KB |
Output is correct |
90 |
Correct |
5 ms |
208 KB |
Output is correct |
91 |
Correct |
3 ms |
208 KB |
Output is correct |
92 |
Correct |
5 ms |
208 KB |
Output is correct |
93 |
Correct |
9 ms |
208 KB |
Output is correct |
94 |
Correct |
6 ms |
208 KB |
Output is correct |
95 |
Correct |
8 ms |
208 KB |
Output is correct |
96 |
Correct |
6 ms |
208 KB |
Output is correct |
97 |
Correct |
2 ms |
208 KB |
Output is correct |