#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
const int N = 2e5 + 5;
int a[N];
int b[N];
int s[N];
int ans;
vector <int> v;
/*vector<int> ask(int i) {
cout << i << '\n';
vector<int> res(2);
cin >> res[0] >> res[1];
return res;
}
*/
void divide(int st, int dr)
{
int mid = (st + dr) / 2;
if (s[mid])
return;
v = ask(mid);
a[mid] = v[0];
b[mid] = v[1];
s[mid] = a[mid] + b[mid];
if (s[mid] == 0)
{
ans = mid;
return;
}
if (ans)
return;
if (!(s[st] == s[mid] && a[mid] == a[st]))
divide(st, mid);
if (ans)
return;
if (!(s[dr] == s[mid] && a[mid] == a[dr]))
divide(mid, dr);
return;
}
int find_best(int n)
{
vector <int> v;
v = ask(0);
a[0] = v[0];
b[0] = v[1];
s[0] = a[0] + b[0];
v = ask(n - 1);
a[n - 1] = v[0];
b[n - 1] = v[1];
s[n - 1] = a[n - 1] + b[n - 1];
if (s[0] == 0)
ans = 0;
if (s[n - 1] == 0)
ans = n - 1;
divide(0, n - 1);
///cout << ans;
return ans;
}/*
int main()
{
find_best(8);
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
288 KB |
Output is correct |
7 |
Correct |
1 ms |
276 KB |
Output is correct |
8 |
Correct |
1 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
288 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
292 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
2 ms |
816 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
6 ms |
1620 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
8 ms |
672 KB |
Output is correct |
16 |
Correct |
18 ms |
2216 KB |
Output is correct |
17 |
Correct |
1 ms |
288 KB |
Output is correct |
18 |
Partially correct |
46 ms |
2620 KB |
Partially correct - number of queries: 5068 |
19 |
Correct |
1 ms |
288 KB |
Output is correct |
20 |
Correct |
9 ms |
680 KB |
Output is correct |
21 |
Correct |
16 ms |
1096 KB |
Output is correct |
22 |
Correct |
4 ms |
592 KB |
Output is correct |
23 |
Correct |
1 ms |
300 KB |
Output is correct |
24 |
Correct |
1 ms |
280 KB |
Output is correct |
25 |
Correct |
16 ms |
1572 KB |
Output is correct |
26 |
Correct |
27 ms |
1532 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
34 ms |
2444 KB |
Output is correct |
29 |
Correct |
29 ms |
2188 KB |
Output is correct |
30 |
Partially correct |
21 ms |
2572 KB |
Partially correct - number of queries: 5022 |
31 |
Correct |
1 ms |
300 KB |
Output is correct |
32 |
Correct |
4 ms |
1188 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
7 ms |
1036 KB |
Output is correct |
35 |
Correct |
2 ms |
712 KB |
Output is correct |
36 |
Correct |
9 ms |
740 KB |
Output is correct |
37 |
Correct |
2 ms |
560 KB |
Output is correct |
38 |
Correct |
1 ms |
336 KB |
Output is correct |
39 |
Correct |
21 ms |
1312 KB |
Output is correct |
40 |
Correct |
43 ms |
2808 KB |
Output is correct |
41 |
Correct |
23 ms |
1584 KB |
Output is correct |
42 |
Correct |
27 ms |
1704 KB |
Output is correct |
43 |
Correct |
21 ms |
1472 KB |
Output is correct |
44 |
Correct |
18 ms |
1184 KB |
Output is correct |
45 |
Correct |
17 ms |
1048 KB |
Output is correct |
46 |
Correct |
1 ms |
300 KB |
Output is correct |
47 |
Correct |
16 ms |
1244 KB |
Output is correct |
48 |
Correct |
15 ms |
1924 KB |
Output is correct |
49 |
Correct |
4 ms |
420 KB |
Output is correct |
50 |
Partially correct |
37 ms |
2592 KB |
Partially correct - number of queries: 5070 |
51 |
Correct |
21 ms |
1232 KB |
Output is correct |
52 |
Correct |
1 ms |
396 KB |
Output is correct |
53 |
Correct |
2 ms |
720 KB |
Output is correct |
54 |
Correct |
15 ms |
1188 KB |
Output is correct |
55 |
Correct |
1 ms |
304 KB |
Output is correct |
56 |
Partially correct |
29 ms |
2544 KB |
Partially correct - number of queries: 5069 |
57 |
Correct |
26 ms |
1988 KB |
Output is correct |
58 |
Correct |
24 ms |
1924 KB |
Output is correct |
59 |
Correct |
30 ms |
1576 KB |
Output is correct |
60 |
Correct |
23 ms |
1656 KB |
Output is correct |
61 |
Correct |
1 ms |
672 KB |
Output is correct |
62 |
Correct |
1 ms |
292 KB |
Output is correct |
63 |
Correct |
2 ms |
676 KB |
Output is correct |
64 |
Correct |
2 ms |
536 KB |
Output is correct |
65 |
Correct |
1 ms |
424 KB |
Output is correct |
66 |
Correct |
1 ms |
304 KB |
Output is correct |
67 |
Correct |
1 ms |
288 KB |
Output is correct |
68 |
Correct |
1 ms |
304 KB |
Output is correct |
69 |
Correct |
1 ms |
328 KB |
Output is correct |
70 |
Correct |
1 ms |
280 KB |
Output is correct |
71 |
Correct |
41 ms |
2512 KB |
Output is correct |
72 |
Correct |
4 ms |
1576 KB |
Output is correct |
73 |
Correct |
37 ms |
2520 KB |
Output is correct |
74 |
Correct |
28 ms |
2608 KB |
Output is correct |
75 |
Correct |
2 ms |
720 KB |
Output is correct |
76 |
Correct |
41 ms |
2580 KB |
Output is correct |
77 |
Partially correct |
55 ms |
2660 KB |
Partially correct - number of queries: 5216 |
78 |
Correct |
5 ms |
1660 KB |
Output is correct |
79 |
Correct |
16 ms |
2568 KB |
Output is correct |
80 |
Partially correct |
54 ms |
2532 KB |
Partially correct - number of queries: 5237 |
81 |
Partially correct |
60 ms |
2536 KB |
Partially correct - number of queries: 5218 |
82 |
Partially correct |
48 ms |
2504 KB |
Partially correct - number of queries: 5216 |
83 |
Correct |
2 ms |
796 KB |
Output is correct |
84 |
Correct |
48 ms |
2632 KB |
Output is correct |
85 |
Partially correct |
22 ms |
2596 KB |
Partially correct - number of queries: 5233 |
86 |
Correct |
10 ms |
1360 KB |
Output is correct |
87 |
Correct |
5 ms |
1316 KB |
Output is correct |
88 |
Correct |
10 ms |
1344 KB |
Output is correct |
89 |
Correct |
7 ms |
1304 KB |
Output is correct |
90 |
Correct |
2 ms |
848 KB |
Output is correct |
91 |
Correct |
5 ms |
976 KB |
Output is correct |
92 |
Correct |
1 ms |
336 KB |
Output is correct |
93 |
Correct |
5 ms |
1056 KB |
Output is correct |
94 |
Correct |
4 ms |
1232 KB |
Output is correct |
95 |
Correct |
3 ms |
1232 KB |
Output is correct |
96 |
Correct |
4 ms |
1104 KB |
Output is correct |
97 |
Correct |
1 ms |
336 KB |
Output is correct |