#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int MX=200010;
bool up[MX];
int L[MX], R[MX], sum, n, ans;
void my_ask(int i){
static set<int> S;
if(S.find(i)!=S.end()) return;
S.insert(i);
vi now=ask(i);
L[i]=now[0], R[i]=now[1];
}
void search(int s, int e, int lc, int rc){
if(s>e) return;
int m=(s+e)/2;
for(int i=m; i<=e; i++){
my_ask(i);
if(L[i]+R[i]==0) ans=i;
if(L[i]+R[i]==sum){
if(lc<L[i]-(i-m)) search(s,m-1,lc,R[i]+i-m);
if(rc<R[i]) search(i+1,e,L[i],rc);
break;
}
}
}
void get(){
for(int i=0; i<min(410, n); i++){
my_ask(i);
sum=max(sum, L[i]+R[i]);
}
}
int find_best(int _n){
n=_n;
get();
search(0,n-1,0,0);
assert(ans>=0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
476 KB |
Output is correct |
4 |
Correct |
6 ms |
476 KB |
Output is correct |
5 |
Correct |
4 ms |
476 KB |
Output is correct |
6 |
Correct |
5 ms |
484 KB |
Output is correct |
7 |
Correct |
6 ms |
564 KB |
Output is correct |
8 |
Correct |
6 ms |
564 KB |
Output is correct |
9 |
Correct |
9 ms |
564 KB |
Output is correct |
10 |
Correct |
8 ms |
564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
564 KB |
Output is correct |
2 |
Correct |
4 ms |
564 KB |
Output is correct |
3 |
Correct |
7 ms |
564 KB |
Output is correct |
4 |
Correct |
6 ms |
672 KB |
Output is correct |
5 |
Correct |
6 ms |
672 KB |
Output is correct |
6 |
Correct |
6 ms |
672 KB |
Output is correct |
7 |
Correct |
4 ms |
672 KB |
Output is correct |
8 |
Correct |
9 ms |
672 KB |
Output is correct |
9 |
Correct |
7 ms |
672 KB |
Output is correct |
10 |
Correct |
6 ms |
672 KB |
Output is correct |
11 |
Correct |
12 ms |
1440 KB |
Output is correct |
12 |
Correct |
10 ms |
1440 KB |
Output is correct |
13 |
Correct |
9 ms |
1440 KB |
Output is correct |
14 |
Correct |
14 ms |
1440 KB |
Output is correct |
15 |
Correct |
42 ms |
2328 KB |
Output is correct |
16 |
Correct |
41 ms |
2328 KB |
Output is correct |
17 |
Correct |
43 ms |
2328 KB |
Output is correct |
18 |
Correct |
43 ms |
2328 KB |
Output is correct |
19 |
Correct |
57 ms |
2328 KB |
Output is correct |
20 |
Correct |
31 ms |
2328 KB |
Output is correct |
21 |
Correct |
41 ms |
2340 KB |
Output is correct |
22 |
Correct |
38 ms |
2340 KB |
Output is correct |
23 |
Correct |
9 ms |
2340 KB |
Output is correct |
24 |
Correct |
11 ms |
2340 KB |
Output is correct |
25 |
Correct |
21 ms |
2340 KB |
Output is correct |
26 |
Correct |
47 ms |
2368 KB |
Output is correct |
27 |
Correct |
7 ms |
2368 KB |
Output is correct |
28 |
Correct |
36 ms |
2368 KB |
Output is correct |
29 |
Correct |
26 ms |
2368 KB |
Output is correct |
30 |
Correct |
59 ms |
2368 KB |
Output is correct |
31 |
Correct |
66 ms |
2368 KB |
Output is correct |
32 |
Correct |
16 ms |
2368 KB |
Output is correct |
33 |
Correct |
3 ms |
2368 KB |
Output is correct |
34 |
Correct |
23 ms |
2368 KB |
Output is correct |
35 |
Correct |
8 ms |
2368 KB |
Output is correct |
36 |
Correct |
40 ms |
2368 KB |
Output is correct |
37 |
Correct |
13 ms |
2368 KB |
Output is correct |
38 |
Correct |
7 ms |
2368 KB |
Output is correct |
39 |
Correct |
47 ms |
2368 KB |
Output is correct |
40 |
Correct |
49 ms |
2368 KB |
Output is correct |
41 |
Correct |
48 ms |
2368 KB |
Output is correct |
42 |
Correct |
48 ms |
2368 KB |
Output is correct |
43 |
Correct |
47 ms |
2368 KB |
Output is correct |
44 |
Correct |
54 ms |
2368 KB |
Output is correct |
45 |
Correct |
45 ms |
2368 KB |
Output is correct |
46 |
Correct |
54 ms |
2368 KB |
Output is correct |
47 |
Correct |
35 ms |
2368 KB |
Output is correct |
48 |
Correct |
56 ms |
2368 KB |
Output is correct |
49 |
Correct |
44 ms |
2368 KB |
Output is correct |
50 |
Correct |
58 ms |
2368 KB |
Output is correct |
51 |
Correct |
46 ms |
2424 KB |
Output is correct |
52 |
Correct |
26 ms |
2424 KB |
Output is correct |
53 |
Correct |
8 ms |
2424 KB |
Output is correct |
54 |
Correct |
56 ms |
2424 KB |
Output is correct |
55 |
Correct |
41 ms |
2424 KB |
Output is correct |
56 |
Correct |
65 ms |
2424 KB |
Output is correct |
57 |
Correct |
67 ms |
2424 KB |
Output is correct |
58 |
Correct |
39 ms |
2424 KB |
Output is correct |
59 |
Correct |
48 ms |
2424 KB |
Output is correct |
60 |
Correct |
50 ms |
2424 KB |
Output is correct |
61 |
Correct |
10 ms |
2424 KB |
Output is correct |
62 |
Correct |
10 ms |
2424 KB |
Output is correct |
63 |
Correct |
8 ms |
2424 KB |
Output is correct |
64 |
Correct |
9 ms |
2424 KB |
Output is correct |
65 |
Correct |
6 ms |
2424 KB |
Output is correct |
66 |
Correct |
11 ms |
2424 KB |
Output is correct |
67 |
Incorrect |
10 ms |
2424 KB |
answer is not correct |
68 |
Halted |
0 ms |
0 KB |
- |