#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef pair<ll , ll> ii;
#define ff first
#define ss second
#define pb push_back
#define in insert
const ll Q = 5e3;
int ans = 0;
int god_number = 0;
void find(ll l, ll r, ll L, ll M, ll R){
if(M <= 0 || r < l) return;
ll m = (l + r)/2;
auto v = ask(m);
if(v[0] + v[1] == god_number){
find(l, m-1, L, v[0] - L, v[1]);
find(m+1, r, v[0], v[1] - R, R);
return;
}
if(v[0] + v[1] == 0){
ans = m;
return;
}
ll L1 = l, R1 = m-1; ll c = 1; M--;
while(L1 <= R1 && M){
v = ask(R1);
if(v[0] + v[1] == 0){
ans = R1; return;
}
if(v[0] + v[1] == god_number){
if(L1 <= R1-1){
find(L1, R1-1, L, v[0] - L, v[1]);
}
find(m+1, r, v[0] + c, v[1] - c - R, R);
return;
}
M--;
R1--;
c++;
}
if(!M) return;
find(m+1, r, L + c, M, R);
return;
}
ll _try(ll n, ll c){
return 0;
}
int find_best(int n) {
if(n < Q){
for(ll i = 0; i < n; i++){
auto v = ask(i);
if(v[0] + v[1] == 0) return i;
}
}
vector < ll > c(500, 0);
ll fact = 475;
for(int i = 0; i <= fact; i++){
auto v = ask(i);
if(v[0] + v[1] == 0) return i;
c[i] = v[0] + v[1];
if(c[i] != god_number){
god_number = max(c[i], god_number);
continue;
}
if(c[i] * c[i] > n){
fact = i;
break;
}
}
ll L = 0;
for(ll i = 0; i <= fact; i++){
if(c[i] != god_number) L++;
}
find(fact + 1, n-1, L , god_number - L, 0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
6 ms |
288 KB |
Output is correct |
3 |
Correct |
5 ms |
292 KB |
Output is correct |
4 |
Correct |
2 ms |
300 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
5 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
288 KB |
Output is correct |
9 |
Correct |
6 ms |
208 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
300 KB |
Output is correct |
2 |
Correct |
4 ms |
436 KB |
Output is correct |
3 |
Correct |
3 ms |
276 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
4 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
5 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
284 KB |
Output is correct |
9 |
Correct |
3 ms |
272 KB |
Output is correct |
10 |
Correct |
6 ms |
304 KB |
Output is correct |
11 |
Correct |
11 ms |
208 KB |
Output is correct |
12 |
Correct |
10 ms |
296 KB |
Output is correct |
13 |
Correct |
6 ms |
284 KB |
Output is correct |
14 |
Correct |
9 ms |
300 KB |
Output is correct |
15 |
Correct |
40 ms |
296 KB |
Output is correct |
16 |
Correct |
43 ms |
208 KB |
Output is correct |
17 |
Correct |
17 ms |
292 KB |
Output is correct |
18 |
Correct |
36 ms |
208 KB |
Output is correct |
19 |
Correct |
3 ms |
272 KB |
Output is correct |
20 |
Correct |
20 ms |
208 KB |
Output is correct |
21 |
Correct |
31 ms |
256 KB |
Output is correct |
22 |
Correct |
27 ms |
296 KB |
Output is correct |
23 |
Correct |
3 ms |
396 KB |
Output is correct |
24 |
Correct |
7 ms |
208 KB |
Output is correct |
25 |
Correct |
32 ms |
208 KB |
Output is correct |
26 |
Correct |
41 ms |
208 KB |
Output is correct |
27 |
Correct |
4 ms |
292 KB |
Output is correct |
28 |
Correct |
36 ms |
208 KB |
Output is correct |
29 |
Correct |
37 ms |
284 KB |
Output is correct |
30 |
Correct |
35 ms |
208 KB |
Output is correct |
31 |
Correct |
16 ms |
288 KB |
Output is correct |
32 |
Correct |
9 ms |
208 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
30 ms |
208 KB |
Output is correct |
35 |
Correct |
6 ms |
276 KB |
Output is correct |
36 |
Correct |
47 ms |
208 KB |
Output is correct |
37 |
Correct |
8 ms |
208 KB |
Output is correct |
38 |
Correct |
3 ms |
344 KB |
Output is correct |
39 |
Correct |
29 ms |
208 KB |
Output is correct |
40 |
Correct |
36 ms |
208 KB |
Output is correct |
41 |
Correct |
31 ms |
208 KB |
Output is correct |
42 |
Correct |
32 ms |
208 KB |
Output is correct |
43 |
Correct |
32 ms |
296 KB |
Output is correct |
44 |
Correct |
37 ms |
292 KB |
Output is correct |
45 |
Correct |
40 ms |
296 KB |
Output is correct |
46 |
Correct |
29 ms |
292 KB |
Output is correct |
47 |
Correct |
36 ms |
288 KB |
Output is correct |
48 |
Correct |
33 ms |
288 KB |
Output is correct |
49 |
Correct |
21 ms |
296 KB |
Output is correct |
50 |
Correct |
32 ms |
208 KB |
Output is correct |
51 |
Correct |
33 ms |
208 KB |
Output is correct |
52 |
Correct |
32 ms |
296 KB |
Output is correct |
53 |
Correct |
6 ms |
272 KB |
Output is correct |
54 |
Correct |
17 ms |
296 KB |
Output is correct |
55 |
Correct |
25 ms |
272 KB |
Output is correct |
56 |
Correct |
37 ms |
288 KB |
Output is correct |
57 |
Correct |
43 ms |
208 KB |
Output is correct |
58 |
Correct |
31 ms |
288 KB |
Output is correct |
59 |
Correct |
53 ms |
208 KB |
Output is correct |
60 |
Correct |
32 ms |
208 KB |
Output is correct |
61 |
Correct |
5 ms |
292 KB |
Output is correct |
62 |
Correct |
4 ms |
208 KB |
Output is correct |
63 |
Correct |
6 ms |
208 KB |
Output is correct |
64 |
Correct |
6 ms |
292 KB |
Output is correct |
65 |
Correct |
4 ms |
288 KB |
Output is correct |
66 |
Correct |
3 ms |
420 KB |
Output is correct |
67 |
Correct |
1 ms |
288 KB |
Output is correct |
68 |
Correct |
4 ms |
292 KB |
Output is correct |
69 |
Correct |
5 ms |
208 KB |
Output is correct |
70 |
Correct |
4 ms |
208 KB |
Output is correct |
71 |
Correct |
36 ms |
208 KB |
Output is correct |
72 |
Correct |
8 ms |
300 KB |
Output is correct |
73 |
Correct |
32 ms |
208 KB |
Output is correct |
74 |
Correct |
19 ms |
304 KB |
Output is correct |
75 |
Correct |
6 ms |
208 KB |
Output is correct |
76 |
Correct |
37 ms |
296 KB |
Output is correct |
77 |
Correct |
46 ms |
208 KB |
Output is correct |
78 |
Correct |
11 ms |
300 KB |
Output is correct |
79 |
Correct |
21 ms |
208 KB |
Output is correct |
80 |
Correct |
31 ms |
208 KB |
Output is correct |
81 |
Correct |
32 ms |
208 KB |
Output is correct |
82 |
Correct |
40 ms |
208 KB |
Output is correct |
83 |
Correct |
4 ms |
208 KB |
Output is correct |
84 |
Correct |
37 ms |
288 KB |
Output is correct |
85 |
Correct |
19 ms |
344 KB |
Output is correct |
86 |
Correct |
5 ms |
208 KB |
Output is correct |
87 |
Correct |
4 ms |
288 KB |
Output is correct |
88 |
Correct |
4 ms |
208 KB |
Output is correct |
89 |
Correct |
4 ms |
208 KB |
Output is correct |
90 |
Correct |
7 ms |
300 KB |
Output is correct |
91 |
Correct |
4 ms |
296 KB |
Output is correct |
92 |
Correct |
3 ms |
208 KB |
Output is correct |
93 |
Correct |
6 ms |
208 KB |
Output is correct |
94 |
Correct |
8 ms |
208 KB |
Output is correct |
95 |
Correct |
6 ms |
300 KB |
Output is correct |
96 |
Correct |
10 ms |
296 KB |
Output is correct |
97 |
Correct |
4 ms |
208 KB |
Output is correct |