#include "prize.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
vector <int> v;
int go (int l, int r, pii left, pii right) {
if (l > r) {
return -1;
}
int mid = (l + r) >> 1;
v = ask(mid);
pii c = {v[0], v[1]};
if (v[0] == 0 && v[1] == 0) {
return mid;
}
if (l == r) {
return -1;
}
int ret = -1;
if (c.second > 0 && c != right) {
ret = go(mid + 1, r, c, right);
}
if (ret == -1 && c.first > 0 && c != left) {
ret = go(l, mid - 1, left, c);
}
return ret;
}
int find_best(int n) {
return go(0, n - 1, {-1, -1}, {-1, -1});
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
308 KB |
Output is correct |
3 |
Correct |
2 ms |
392 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
388 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
396 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
304 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Correct |
2 ms |
296 KB |
Output is correct |
8 |
Correct |
2 ms |
304 KB |
Output is correct |
9 |
Correct |
2 ms |
292 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
11 |
Correct |
5 ms |
308 KB |
Output is correct |
12 |
Correct |
6 ms |
248 KB |
Output is correct |
13 |
Correct |
2 ms |
248 KB |
Output is correct |
14 |
Correct |
10 ms |
248 KB |
Output is correct |
15 |
Correct |
40 ms |
248 KB |
Output is correct |
16 |
Correct |
12 ms |
304 KB |
Output is correct |
17 |
Partially correct |
36 ms |
380 KB |
Partially correct - number of queries: 5065 |
18 |
Correct |
2 ms |
248 KB |
Output is correct |
19 |
Correct |
49 ms |
248 KB |
Output is correct |
20 |
Correct |
28 ms |
296 KB |
Output is correct |
21 |
Correct |
40 ms |
248 KB |
Output is correct |
22 |
Correct |
29 ms |
388 KB |
Output is correct |
23 |
Correct |
4 ms |
248 KB |
Output is correct |
24 |
Correct |
8 ms |
252 KB |
Output is correct |
25 |
Correct |
23 ms |
376 KB |
Output is correct |
26 |
Correct |
25 ms |
304 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
4 ms |
248 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
3 ms |
392 KB |
Output is correct |
31 |
Correct |
53 ms |
392 KB |
Output is correct |
32 |
Correct |
4 ms |
248 KB |
Output is correct |
33 |
Correct |
2 ms |
248 KB |
Output is correct |
34 |
Correct |
35 ms |
376 KB |
Output is correct |
35 |
Correct |
3 ms |
248 KB |
Output is correct |
36 |
Correct |
38 ms |
248 KB |
Output is correct |
37 |
Correct |
7 ms |
296 KB |
Output is correct |
38 |
Correct |
3 ms |
248 KB |
Output is correct |
39 |
Correct |
30 ms |
308 KB |
Output is correct |
40 |
Correct |
2 ms |
248 KB |
Output is correct |
41 |
Correct |
19 ms |
248 KB |
Output is correct |
42 |
Correct |
13 ms |
376 KB |
Output is correct |
43 |
Correct |
29 ms |
376 KB |
Output is correct |
44 |
Correct |
37 ms |
280 KB |
Output is correct |
45 |
Correct |
43 ms |
248 KB |
Output is correct |
46 |
Partially correct |
57 ms |
308 KB |
Partially correct - number of queries: 5035 |
47 |
Correct |
22 ms |
308 KB |
Output is correct |
48 |
Correct |
20 ms |
308 KB |
Output is correct |
49 |
Correct |
42 ms |
248 KB |
Output is correct |
50 |
Correct |
2 ms |
248 KB |
Output is correct |
51 |
Correct |
26 ms |
248 KB |
Output is correct |
52 |
Partially correct |
48 ms |
248 KB |
Partially correct - number of queries: 5027 |
53 |
Correct |
2 ms |
292 KB |
Output is correct |
54 |
Correct |
31 ms |
248 KB |
Output is correct |
55 |
Partially correct |
59 ms |
248 KB |
Partially correct - number of queries: 5054 |
56 |
Correct |
2 ms |
312 KB |
Output is correct |
57 |
Correct |
16 ms |
376 KB |
Output is correct |
58 |
Correct |
16 ms |
248 KB |
Output is correct |
59 |
Correct |
22 ms |
248 KB |
Output is correct |
60 |
Correct |
17 ms |
252 KB |
Output is correct |
61 |
Correct |
2 ms |
392 KB |
Output is correct |
62 |
Correct |
3 ms |
248 KB |
Output is correct |
63 |
Correct |
2 ms |
248 KB |
Output is correct |
64 |
Correct |
3 ms |
248 KB |
Output is correct |
65 |
Correct |
2 ms |
376 KB |
Output is correct |
66 |
Correct |
2 ms |
376 KB |
Output is correct |
67 |
Correct |
2 ms |
248 KB |
Output is correct |
68 |
Correct |
2 ms |
248 KB |
Output is correct |
69 |
Correct |
2 ms |
248 KB |
Output is correct |
70 |
Correct |
2 ms |
404 KB |
Output is correct |
71 |
Correct |
46 ms |
248 KB |
Output is correct |
72 |
Correct |
7 ms |
248 KB |
Output is correct |
73 |
Correct |
52 ms |
248 KB |
Output is correct |
74 |
Correct |
32 ms |
504 KB |
Output is correct |
75 |
Correct |
3 ms |
248 KB |
Output is correct |
76 |
Correct |
44 ms |
248 KB |
Output is correct |
77 |
Partially correct |
46 ms |
376 KB |
Partially correct - number of queries: 5217 |
78 |
Correct |
8 ms |
248 KB |
Output is correct |
79 |
Correct |
37 ms |
248 KB |
Output is correct |
80 |
Partially correct |
55 ms |
248 KB |
Partially correct - number of queries: 5152 |
81 |
Partially correct |
44 ms |
296 KB |
Partially correct - number of queries: 5196 |
82 |
Partially correct |
57 ms |
248 KB |
Partially correct - number of queries: 5143 |
83 |
Correct |
3 ms |
308 KB |
Output is correct |
84 |
Correct |
42 ms |
248 KB |
Output is correct |
85 |
Partially correct |
56 ms |
248 KB |
Partially correct - number of queries: 5222 |
86 |
Correct |
8 ms |
376 KB |
Output is correct |
87 |
Correct |
5 ms |
248 KB |
Output is correct |
88 |
Correct |
8 ms |
248 KB |
Output is correct |
89 |
Correct |
4 ms |
376 KB |
Output is correct |
90 |
Correct |
3 ms |
248 KB |
Output is correct |
91 |
Correct |
3 ms |
392 KB |
Output is correct |
92 |
Correct |
2 ms |
248 KB |
Output is correct |
93 |
Correct |
5 ms |
248 KB |
Output is correct |
94 |
Correct |
6 ms |
252 KB |
Output is correct |
95 |
Correct |
5 ms |
248 KB |
Output is correct |
96 |
Correct |
4 ms |
376 KB |
Output is correct |
97 |
Correct |
2 ms |
248 KB |
Output is correct |