#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
vector< pair<int,int> > v;
int sum;
int ans;
void recur(int l, int r, int lhs, int rhs) {
if(ans!=-1) return;
if(l>r) return;
int mid = (l+r)/2;
for(int i=mid; i<=r; i++) {
vector<int> tmp = ask(i);
if(tmp[0]+tmp[1]==0) {
ans=i;
return;
}
if(tmp[0]-lhs>0) recur(l, mid-1, lhs, tmp[1]);
if(tmp[1]-rhs>0) recur(i+1, r, tmp[0], rhs);
v.push_back({tmp[0]+tmp[1], i});
return;
}
}
int find_best(int n) {
if(n<=5000) {
for(int i=0; i<n; i++) {
vector<int> tmp = ask(i);
if(tmp[0]+tmp[1]==0) return i;
}
}
sum = 0;
for(int tmp=sqrt(sqrt(n)); tmp>=2; tmp=sqrt(tmp)) {
sum += tmp;
}
sum++;
ans = -1;
recur(0, n-1, 0, 0);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
260 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
264 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
288 KB |
Output is correct |
9 |
Correct |
0 ms |
280 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
264 KB |
Output is correct |
8 |
Correct |
1 ms |
284 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
3 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
260 KB |
Output is correct |
13 |
Correct |
5 ms |
272 KB |
Output is correct |
14 |
Correct |
2 ms |
200 KB |
Output is correct |
15 |
Correct |
5 ms |
276 KB |
Output is correct |
16 |
Correct |
27 ms |
324 KB |
Output is correct |
17 |
Correct |
1 ms |
200 KB |
Output is correct |
18 |
Correct |
39 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
200 KB |
Output is correct |
20 |
Correct |
10 ms |
200 KB |
Output is correct |
21 |
Correct |
12 ms |
268 KB |
Output is correct |
22 |
Correct |
4 ms |
272 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
260 KB |
Output is correct |
25 |
Correct |
16 ms |
284 KB |
Output is correct |
26 |
Correct |
18 ms |
276 KB |
Output is correct |
27 |
Correct |
1 ms |
260 KB |
Output is correct |
28 |
Correct |
15 ms |
388 KB |
Output is correct |
29 |
Correct |
22 ms |
276 KB |
Output is correct |
30 |
Correct |
17 ms |
512 KB |
Output is correct |
31 |
Correct |
1 ms |
320 KB |
Output is correct |
32 |
Correct |
3 ms |
276 KB |
Output is correct |
33 |
Correct |
1 ms |
200 KB |
Output is correct |
34 |
Correct |
12 ms |
200 KB |
Output is correct |
35 |
Correct |
2 ms |
200 KB |
Output is correct |
36 |
Correct |
10 ms |
272 KB |
Output is correct |
37 |
Correct |
1 ms |
280 KB |
Output is correct |
38 |
Correct |
1 ms |
260 KB |
Output is correct |
39 |
Correct |
20 ms |
280 KB |
Output is correct |
40 |
Correct |
14 ms |
356 KB |
Output is correct |
41 |
Correct |
17 ms |
272 KB |
Output is correct |
42 |
Correct |
19 ms |
276 KB |
Output is correct |
43 |
Correct |
20 ms |
392 KB |
Output is correct |
44 |
Correct |
19 ms |
200 KB |
Output is correct |
45 |
Correct |
10 ms |
288 KB |
Output is correct |
46 |
Correct |
1 ms |
200 KB |
Output is correct |
47 |
Correct |
17 ms |
200 KB |
Output is correct |
48 |
Correct |
32 ms |
276 KB |
Output is correct |
49 |
Correct |
3 ms |
280 KB |
Output is correct |
50 |
Correct |
34 ms |
300 KB |
Output is correct |
51 |
Correct |
15 ms |
288 KB |
Output is correct |
52 |
Correct |
1 ms |
268 KB |
Output is correct |
53 |
Correct |
2 ms |
260 KB |
Output is correct |
54 |
Correct |
17 ms |
300 KB |
Output is correct |
55 |
Correct |
1 ms |
200 KB |
Output is correct |
56 |
Correct |
38 ms |
320 KB |
Output is correct |
57 |
Correct |
24 ms |
320 KB |
Output is correct |
58 |
Incorrect |
30 ms |
420 KB |
Integer -1 violates the range [0, 199999] |
59 |
Halted |
0 ms |
0 KB |
- |