#include "prize.h"
#include<vector>
using namespace std;
int ans[200000][2];
int maximo;
void q(int x){
if(ans[x][0]!=-1){
return;
}
vector<int> v=ask(x);
ans[x][0]=v[0];
ans[x][1]=v[1];
}
bool L(int i){
q(i);
if(ans[i][0]+ans[i][1]==maximo)return true;
return false;
}
int find_best(int n) {
for(int i = 0; i < n; i++) {
ans[i][0]=-1;
ans[i][1]=-1;
}
maximo=0;
int d=500;
for(int i=0;i<d;i++){
q(i);
if(ans[i][0]+ans[i][1]>maximo)maximo=ans[i][0]+ans[i][1];
if(ans[i][0]+ans[i][1]==0)return i;
}
int pointer=d;
while(pointer<n){
q(pointer);
if(ans[pointer][0]+ans[pointer][1]==0)return pointer;
if(ans[pointer][0]+ans[pointer][1]==maximo){
int lo=pointer;
int hi=n;
while(hi-lo>1){
int mid=(lo+hi)/2;
if(L(mid)){
if(ans[mid][0]==ans[pointer][0]){
lo=mid;
}else hi=mid;
}else{
hi=mid;
}
}
pointer=lo;
}
pointer++;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
1828 KB |
Output is correct |
2 |
Correct |
9 ms |
1848 KB |
Output is correct |
3 |
Correct |
9 ms |
1900 KB |
Output is correct |
4 |
Correct |
10 ms |
1976 KB |
Output is correct |
5 |
Correct |
6 ms |
2220 KB |
Output is correct |
6 |
Correct |
4 ms |
2220 KB |
Output is correct |
7 |
Correct |
7 ms |
2220 KB |
Output is correct |
8 |
Correct |
15 ms |
2220 KB |
Output is correct |
9 |
Correct |
13 ms |
2220 KB |
Output is correct |
10 |
Correct |
6 ms |
2220 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
2220 KB |
Output is correct |
2 |
Correct |
8 ms |
2220 KB |
Output is correct |
3 |
Correct |
8 ms |
2220 KB |
Output is correct |
4 |
Correct |
12 ms |
2220 KB |
Output is correct |
5 |
Correct |
13 ms |
2220 KB |
Output is correct |
6 |
Correct |
4 ms |
2220 KB |
Output is correct |
7 |
Correct |
9 ms |
2220 KB |
Output is correct |
8 |
Correct |
10 ms |
2220 KB |
Output is correct |
9 |
Correct |
11 ms |
2220 KB |
Output is correct |
10 |
Correct |
10 ms |
2220 KB |
Output is correct |
11 |
Correct |
16 ms |
2220 KB |
Output is correct |
12 |
Correct |
10 ms |
2220 KB |
Output is correct |
13 |
Correct |
17 ms |
2220 KB |
Output is correct |
14 |
Correct |
13 ms |
2220 KB |
Output is correct |
15 |
Correct |
24 ms |
2220 KB |
Output is correct |
16 |
Partially correct |
86 ms |
2220 KB |
Partially correct - number of queries: 7231 |
17 |
Correct |
9 ms |
2220 KB |
Output is correct |
18 |
Partially correct |
108 ms |
2220 KB |
Partially correct - number of queries: 8371 |
19 |
Correct |
10 ms |
2220 KB |
Output is correct |
20 |
Correct |
30 ms |
2220 KB |
Output is correct |
21 |
Correct |
63 ms |
2220 KB |
Output is correct |
22 |
Correct |
23 ms |
2220 KB |
Output is correct |
23 |
Correct |
8 ms |
2220 KB |
Output is correct |
24 |
Correct |
10 ms |
2220 KB |
Output is correct |
25 |
Correct |
54 ms |
2220 KB |
Output is correct |
26 |
Correct |
68 ms |
2220 KB |
Output is correct |
27 |
Correct |
13 ms |
2220 KB |
Output is correct |
28 |
Partially correct |
104 ms |
2220 KB |
Partially correct - number of queries: 7910 |
29 |
Partially correct |
69 ms |
2220 KB |
Partially correct - number of queries: 6122 |
30 |
Partially correct |
81 ms |
2220 KB |
Partially correct - number of queries: 8325 |
31 |
Correct |
8 ms |
2220 KB |
Output is correct |
32 |
Correct |
19 ms |
2220 KB |
Output is correct |
33 |
Correct |
3 ms |
2220 KB |
Output is correct |
34 |
Correct |
44 ms |
2220 KB |
Output is correct |
35 |
Correct |
7 ms |
2220 KB |
Output is correct |
36 |
Correct |
39 ms |
2220 KB |
Output is correct |
37 |
Correct |
11 ms |
2220 KB |
Output is correct |
38 |
Correct |
12 ms |
2220 KB |
Output is correct |
39 |
Correct |
41 ms |
2220 KB |
Output is correct |
40 |
Partially correct |
58 ms |
2220 KB |
Partially correct - number of queries: 7213 |
41 |
Partially correct |
93 ms |
2220 KB |
Partially correct - number of queries: 5215 |
42 |
Partially correct |
61 ms |
2220 KB |
Partially correct - number of queries: 5215 |
43 |
Correct |
54 ms |
2220 KB |
Output is correct |
44 |
Correct |
48 ms |
2220 KB |
Output is correct |
45 |
Correct |
50 ms |
2220 KB |
Output is correct |
46 |
Correct |
10 ms |
2220 KB |
Output is correct |
47 |
Correct |
39 ms |
2220 KB |
Output is correct |
48 |
Partially correct |
113 ms |
2220 KB |
Partially correct - number of queries: 6336 |
49 |
Correct |
16 ms |
2220 KB |
Output is correct |
50 |
Partially correct |
77 ms |
2220 KB |
Partially correct - number of queries: 8373 |
51 |
Correct |
27 ms |
2220 KB |
Output is correct |
52 |
Correct |
6 ms |
2220 KB |
Output is correct |
53 |
Correct |
9 ms |
2220 KB |
Output is correct |
54 |
Correct |
35 ms |
2220 KB |
Output is correct |
55 |
Correct |
10 ms |
2220 KB |
Output is correct |
56 |
Partially correct |
61 ms |
2220 KB |
Partially correct - number of queries: 8373 |
57 |
Partially correct |
68 ms |
2220 KB |
Partially correct - number of queries: 6248 |
58 |
Partially correct |
58 ms |
2220 KB |
Partially correct - number of queries: 6322 |
59 |
Partially correct |
51 ms |
2220 KB |
Partially correct - number of queries: 5211 |
60 |
Correct |
58 ms |
2220 KB |
Output is correct |
61 |
Correct |
6 ms |
2220 KB |
Output is correct |
62 |
Correct |
14 ms |
2220 KB |
Output is correct |
63 |
Correct |
12 ms |
2220 KB |
Output is correct |
64 |
Correct |
9 ms |
2220 KB |
Output is correct |
65 |
Correct |
10 ms |
2220 KB |
Output is correct |
66 |
Correct |
15 ms |
2220 KB |
Output is correct |
67 |
Correct |
10 ms |
2220 KB |
Output is correct |
68 |
Correct |
10 ms |
2220 KB |
Output is correct |
69 |
Correct |
9 ms |
2220 KB |
Output is correct |
70 |
Correct |
12 ms |
2220 KB |
Output is correct |
71 |
Partially correct |
89 ms |
2220 KB |
Partially correct - number of queries: 8239 |
72 |
Correct |
14 ms |
2220 KB |
Output is correct |
73 |
Partially correct |
66 ms |
2220 KB |
Partially correct - number of queries: 8153 |
74 |
Partially correct |
75 ms |
2220 KB |
Partially correct - number of queries: 8197 |
75 |
Correct |
11 ms |
2220 KB |
Output is correct |
76 |
Partially correct |
76 ms |
2220 KB |
Partially correct - number of queries: 7142 |
77 |
Partially correct |
58 ms |
2220 KB |
Partially correct - number of queries: 8400 |
78 |
Correct |
16 ms |
2220 KB |
Output is correct |
79 |
Correct |
36 ms |
2220 KB |
Output is correct |
80 |
Partially correct |
79 ms |
2220 KB |
Partially correct - number of queries: 8443 |
81 |
Partially correct |
90 ms |
2220 KB |
Partially correct - number of queries: 8406 |
82 |
Partially correct |
87 ms |
2220 KB |
Partially correct - number of queries: 8323 |
83 |
Correct |
11 ms |
2220 KB |
Output is correct |
84 |
Partially correct |
84 ms |
2220 KB |
Partially correct - number of queries: 6940 |
85 |
Partially correct |
57 ms |
2220 KB |
Partially correct - number of queries: 8416 |
86 |
Correct |
10 ms |
2220 KB |
Output is correct |
87 |
Correct |
10 ms |
2220 KB |
Output is correct |
88 |
Correct |
9 ms |
2220 KB |
Output is correct |
89 |
Correct |
9 ms |
2220 KB |
Output is correct |
90 |
Correct |
10 ms |
2220 KB |
Output is correct |
91 |
Correct |
9 ms |
2220 KB |
Output is correct |
92 |
Correct |
10 ms |
2220 KB |
Output is correct |
93 |
Correct |
20 ms |
2220 KB |
Output is correct |
94 |
Correct |
15 ms |
2220 KB |
Output is correct |
95 |
Correct |
14 ms |
2220 KB |
Output is correct |
96 |
Correct |
14 ms |
2220 KB |
Output is correct |
97 |
Correct |
9 ms |
2220 KB |
Output is correct |