#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
vector <int> v;
int maxx,idx,l,le,ri,mid,ans;
int find_best(int n) {
for(int i=0;i<500;i++) {
v=ask(i);
if(v[0]+v[1]==0) return i;
if(v[0]+v[1]>maxx) {
maxx=v[0]+v[1];
idx=i;
l=v[0];
}
}
while(true) {
le=idx+1; ri=n-1;
while(le<=ri) {
mid=(le+ri)/2;
v=ask(mid);
if(v[0]+v[1]==maxx && v[0]==l) le=mid+1;
else { ri=mid-1; }
if(v[0]+v[1]!=maxx) ans=mid;
}
for(int i=ans;i<n;i++) {
v=ask(i);
if(v[0]+v[1]==0) return i;
if(v[0]+v[1]==maxx) {
idx=i;
l=v[0];
break;
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
256 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
9 |
Correct |
6 ms |
256 KB |
Output is correct |
10 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
372 KB |
Output is correct |
9 |
Correct |
6 ms |
256 KB |
Output is correct |
10 |
Correct |
6 ms |
256 KB |
Output is correct |
11 |
Correct |
10 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
11 ms |
256 KB |
Output is correct |
14 |
Correct |
9 ms |
256 KB |
Output is correct |
15 |
Correct |
10 ms |
376 KB |
Output is correct |
16 |
Partially correct |
64 ms |
256 KB |
Partially correct - number of queries: 7832 |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Partially correct |
88 ms |
256 KB |
Partially correct - number of queries: 9108 |
19 |
Correct |
5 ms |
256 KB |
Output is correct |
20 |
Correct |
14 ms |
384 KB |
Output is correct |
21 |
Correct |
39 ms |
256 KB |
Output is correct |
22 |
Correct |
12 ms |
256 KB |
Output is correct |
23 |
Correct |
7 ms |
256 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Partially correct |
46 ms |
256 KB |
Partially correct - number of queries: 5371 |
26 |
Partially correct |
44 ms |
364 KB |
Partially correct - number of queries: 5289 |
27 |
Correct |
4 ms |
256 KB |
Output is correct |
28 |
Partially correct |
68 ms |
380 KB |
Partially correct - number of queries: 8666 |
29 |
Partially correct |
36 ms |
256 KB |
Partially correct - number of queries: 6706 |
30 |
Partially correct |
79 ms |
256 KB |
Partially correct - number of queries: 9051 |
31 |
Correct |
3 ms |
376 KB |
Output is correct |
32 |
Correct |
10 ms |
288 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
31 ms |
256 KB |
Output is correct |
35 |
Correct |
4 ms |
384 KB |
Output is correct |
36 |
Correct |
21 ms |
256 KB |
Output is correct |
37 |
Correct |
7 ms |
256 KB |
Output is correct |
38 |
Correct |
3 ms |
376 KB |
Output is correct |
39 |
Correct |
26 ms |
256 KB |
Output is correct |
40 |
Partially correct |
73 ms |
256 KB |
Partially correct - number of queries: 7805 |
41 |
Partially correct |
58 ms |
256 KB |
Partially correct - number of queries: 5648 |
42 |
Partially correct |
52 ms |
256 KB |
Partially correct - number of queries: 5648 |
43 |
Partially correct |
44 ms |
256 KB |
Partially correct - number of queries: 5147 |
44 |
Correct |
40 ms |
256 KB |
Output is correct |
45 |
Correct |
33 ms |
256 KB |
Output is correct |
46 |
Correct |
5 ms |
256 KB |
Output is correct |
47 |
Correct |
43 ms |
256 KB |
Output is correct |
48 |
Partially correct |
55 ms |
256 KB |
Partially correct - number of queries: 6864 |
49 |
Correct |
13 ms |
256 KB |
Output is correct |
50 |
Partially correct |
75 ms |
256 KB |
Partially correct - number of queries: 9105 |
51 |
Correct |
41 ms |
256 KB |
Output is correct |
52 |
Correct |
6 ms |
256 KB |
Output is correct |
53 |
Correct |
6 ms |
256 KB |
Output is correct |
54 |
Correct |
52 ms |
256 KB |
Output is correct |
55 |
Correct |
4 ms |
256 KB |
Output is correct |
56 |
Partially correct |
71 ms |
256 KB |
Partially correct - number of queries: 9107 |
57 |
Partially correct |
70 ms |
256 KB |
Partially correct - number of queries: 6787 |
58 |
Partially correct |
58 ms |
256 KB |
Partially correct - number of queries: 6894 |
59 |
Partially correct |
43 ms |
368 KB |
Partially correct - number of queries: 5648 |
60 |
Partially correct |
56 ms |
364 KB |
Partially correct - number of queries: 5279 |
61 |
Correct |
9 ms |
256 KB |
Output is correct |
62 |
Correct |
5 ms |
256 KB |
Output is correct |
63 |
Correct |
7 ms |
256 KB |
Output is correct |
64 |
Correct |
7 ms |
256 KB |
Output is correct |
65 |
Correct |
6 ms |
256 KB |
Output is correct |
66 |
Correct |
9 ms |
360 KB |
Output is correct |
67 |
Correct |
5 ms |
256 KB |
Output is correct |
68 |
Correct |
4 ms |
256 KB |
Output is correct |
69 |
Correct |
10 ms |
256 KB |
Output is correct |
70 |
Correct |
6 ms |
256 KB |
Output is correct |
71 |
Partially correct |
95 ms |
256 KB |
Partially correct - number of queries: 9228 |
72 |
Correct |
14 ms |
256 KB |
Output is correct |
73 |
Partially correct |
90 ms |
256 KB |
Partially correct - number of queries: 9122 |
74 |
Partially correct |
85 ms |
256 KB |
Partially correct - number of queries: 9164 |
75 |
Correct |
7 ms |
256 KB |
Output is correct |
76 |
Partially correct |
76 ms |
256 KB |
Partially correct - number of queries: 7947 |
77 |
Partially correct |
81 ms |
256 KB |
Partially correct - number of queries: 9115 |
78 |
Correct |
7 ms |
384 KB |
Output is correct |
79 |
Correct |
39 ms |
256 KB |
Output is correct |
80 |
Partially correct |
69 ms |
256 KB |
Partially correct - number of queries: 9110 |
81 |
Partially correct |
68 ms |
256 KB |
Partially correct - number of queries: 9112 |
82 |
Partially correct |
79 ms |
256 KB |
Partially correct - number of queries: 9046 |
83 |
Correct |
6 ms |
256 KB |
Output is correct |
84 |
Partially correct |
68 ms |
256 KB |
Partially correct - number of queries: 7558 |
85 |
Partially correct |
77 ms |
256 KB |
Partially correct - number of queries: 9146 |
86 |
Correct |
6 ms |
256 KB |
Output is correct |
87 |
Correct |
3 ms |
384 KB |
Output is correct |
88 |
Correct |
3 ms |
384 KB |
Output is correct |
89 |
Correct |
6 ms |
256 KB |
Output is correct |
90 |
Correct |
5 ms |
256 KB |
Output is correct |
91 |
Correct |
6 ms |
384 KB |
Output is correct |
92 |
Correct |
4 ms |
256 KB |
Output is correct |
93 |
Correct |
9 ms |
256 KB |
Output is correct |
94 |
Correct |
9 ms |
256 KB |
Output is correct |
95 |
Correct |
8 ms |
256 KB |
Output is correct |
96 |
Correct |
9 ms |
256 KB |
Output is correct |
97 |
Correct |
5 ms |
256 KB |
Output is correct |