#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define lg length()
#define pb push_back
#define INF 2000000005
#define LINF 1000000000000000005
#define all(x) (x).begin(), (x).end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
#include "prize.h"
vector<int> l,r;
vector<int> res;
int found = 0, mx = 0;
void Qry(int p){
if(l[p] != -1) return;
res = ask(p);
l[p] = res[0]; r[p] = res[1];
}
void BS(int L, int R){
if(found) return;
if(R-L < 2) return;
if(l[L] == l[R] && l[L] == l[R]) return;
if(l[L] == 0 && r[L] == 0) found = 1;
int M = (L+R)/2;
Qry(M);
if(l[M] + r[M] != l[L] + r[L] && l[M] + r[M] != l[L] + r[L] && M - 1 > L){
M--;
Qry(M);
if(l[M] + r[M] != l[L] + r[L] && l[M] + r[M] != l[L] + r[L] && M + 2 < R){
M+=2;
Qry(M);
}
}
BS(L, M);
BS(M, R);
}
int find_best(int n) {
l.resize(n, -1);
r.resize(n, -1);
Qry(0); Qry(n-1);
BS(0, n-1);
for(int i=0;i<n;i++){
if(l[i] == 0 && r[i] == 0) return i;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1880 KB |
Output is correct |
2 |
Correct |
2 ms |
1820 KB |
Output is correct |
3 |
Correct |
2 ms |
1820 KB |
Output is correct |
4 |
Correct |
2 ms |
1864 KB |
Output is correct |
5 |
Correct |
3 ms |
1908 KB |
Output is correct |
6 |
Correct |
2 ms |
1824 KB |
Output is correct |
7 |
Correct |
1 ms |
1816 KB |
Output is correct |
8 |
Correct |
2 ms |
1824 KB |
Output is correct |
9 |
Correct |
1 ms |
1820 KB |
Output is correct |
10 |
Correct |
2 ms |
1864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1812 KB |
Output is correct |
2 |
Correct |
2 ms |
1864 KB |
Output is correct |
3 |
Correct |
2 ms |
1856 KB |
Output is correct |
4 |
Correct |
2 ms |
1824 KB |
Output is correct |
5 |
Correct |
2 ms |
1812 KB |
Output is correct |
6 |
Correct |
1 ms |
1812 KB |
Output is correct |
7 |
Correct |
2 ms |
1876 KB |
Output is correct |
8 |
Correct |
2 ms |
1820 KB |
Output is correct |
9 |
Correct |
3 ms |
1864 KB |
Output is correct |
10 |
Correct |
2 ms |
1864 KB |
Output is correct |
11 |
Correct |
3 ms |
1820 KB |
Output is correct |
12 |
Correct |
7 ms |
1856 KB |
Output is correct |
13 |
Correct |
6 ms |
1816 KB |
Output is correct |
14 |
Correct |
3 ms |
516 KB |
Output is correct |
15 |
Correct |
8 ms |
1856 KB |
Output is correct |
16 |
Correct |
31 ms |
1860 KB |
Output is correct |
17 |
Correct |
2 ms |
1820 KB |
Output is correct |
18 |
Correct |
39 ms |
1944 KB |
Output is correct |
19 |
Correct |
2 ms |
1804 KB |
Output is correct |
20 |
Correct |
18 ms |
1076 KB |
Output is correct |
21 |
Correct |
21 ms |
1856 KB |
Output is correct |
22 |
Correct |
47 ms |
1860 KB |
Output is correct |
23 |
Correct |
2 ms |
1812 KB |
Output is correct |
24 |
Correct |
11 ms |
1812 KB |
Output is correct |
25 |
Correct |
18 ms |
1820 KB |
Output is correct |
26 |
Correct |
45 ms |
1860 KB |
Output is correct |
27 |
Correct |
4 ms |
1824 KB |
Output is correct |
28 |
Correct |
48 ms |
1856 KB |
Output is correct |
29 |
Correct |
29 ms |
1824 KB |
Output is correct |
30 |
Correct |
40 ms |
1820 KB |
Output is correct |
31 |
Correct |
29 ms |
1856 KB |
Output is correct |
32 |
Correct |
6 ms |
1860 KB |
Output is correct |
33 |
Correct |
1 ms |
200 KB |
Output is correct |
34 |
Correct |
11 ms |
1860 KB |
Output is correct |
35 |
Correct |
2 ms |
1864 KB |
Output is correct |
36 |
Correct |
61 ms |
1864 KB |
Output is correct |
37 |
Correct |
4 ms |
1856 KB |
Output is correct |
38 |
Correct |
2 ms |
1852 KB |
Output is correct |
39 |
Correct |
46 ms |
1856 KB |
Output is correct |
40 |
Correct |
39 ms |
1856 KB |
Output is correct |
41 |
Correct |
39 ms |
1856 KB |
Output is correct |
42 |
Correct |
34 ms |
1860 KB |
Output is correct |
43 |
Correct |
50 ms |
1856 KB |
Output is correct |
44 |
Correct |
20 ms |
1856 KB |
Output is correct |
45 |
Correct |
42 ms |
1812 KB |
Output is correct |
46 |
Correct |
2 ms |
1864 KB |
Output is correct |
47 |
Correct |
49 ms |
1856 KB |
Output is correct |
48 |
Correct |
39 ms |
1856 KB |
Output is correct |
49 |
Correct |
3 ms |
1856 KB |
Output is correct |
50 |
Correct |
29 ms |
1860 KB |
Output is correct |
51 |
Correct |
47 ms |
1852 KB |
Output is correct |
52 |
Correct |
2 ms |
1860 KB |
Output is correct |
53 |
Correct |
3 ms |
1816 KB |
Output is correct |
54 |
Correct |
57 ms |
1860 KB |
Output is correct |
55 |
Correct |
2 ms |
1860 KB |
Output is correct |
56 |
Correct |
61 ms |
1816 KB |
Output is correct |
57 |
Correct |
24 ms |
1868 KB |
Output is correct |
58 |
Correct |
42 ms |
1860 KB |
Output is correct |
59 |
Correct |
43 ms |
1860 KB |
Output is correct |
60 |
Correct |
22 ms |
1856 KB |
Output is correct |
61 |
Correct |
3 ms |
1860 KB |
Output is correct |
62 |
Correct |
2 ms |
1820 KB |
Output is correct |
63 |
Correct |
2 ms |
1820 KB |
Output is correct |
64 |
Correct |
2 ms |
1816 KB |
Output is correct |
65 |
Correct |
2 ms |
1860 KB |
Output is correct |
66 |
Correct |
2 ms |
1856 KB |
Output is correct |
67 |
Correct |
2 ms |
1864 KB |
Output is correct |
68 |
Correct |
2 ms |
1816 KB |
Output is correct |
69 |
Correct |
2 ms |
1812 KB |
Output is correct |
70 |
Correct |
2 ms |
1828 KB |
Output is correct |
71 |
Correct |
54 ms |
1864 KB |
Output is correct |
72 |
Correct |
7 ms |
1880 KB |
Output is correct |
73 |
Correct |
55 ms |
1864 KB |
Output is correct |
74 |
Correct |
53 ms |
1864 KB |
Output is correct |
75 |
Correct |
3 ms |
1864 KB |
Output is correct |
76 |
Correct |
62 ms |
1864 KB |
Output is correct |
77 |
Correct |
39 ms |
1864 KB |
Output is correct |
78 |
Correct |
7 ms |
1864 KB |
Output is correct |
79 |
Correct |
26 ms |
1860 KB |
Output is correct |
80 |
Correct |
76 ms |
1864 KB |
Output is correct |
81 |
Correct |
55 ms |
1856 KB |
Output is correct |
82 |
Correct |
77 ms |
1864 KB |
Output is correct |
83 |
Correct |
4 ms |
1864 KB |
Output is correct |
84 |
Correct |
45 ms |
1860 KB |
Output is correct |
85 |
Correct |
93 ms |
1864 KB |
Output is correct |
86 |
Correct |
15 ms |
1860 KB |
Output is correct |
87 |
Correct |
6 ms |
1880 KB |
Output is correct |
88 |
Correct |
12 ms |
1864 KB |
Output is correct |
89 |
Correct |
10 ms |
1864 KB |
Output is correct |
90 |
Correct |
4 ms |
1864 KB |
Output is correct |
91 |
Correct |
6 ms |
1876 KB |
Output is correct |
92 |
Correct |
2 ms |
1864 KB |
Output is correct |
93 |
Correct |
5 ms |
1864 KB |
Output is correct |
94 |
Correct |
4 ms |
1864 KB |
Output is correct |
95 |
Correct |
7 ms |
1864 KB |
Output is correct |
96 |
Correct |
4 ms |
1880 KB |
Output is correct |
97 |
Correct |
2 ms |
1880 KB |
Output is correct |