#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
pair<int, int> pr[200100];
bool used[200100];
pair<int, int> myask(int pos){
if (used[pos]){
return pr[pos];
}
used[pos] = 1;
vector <int> vec = ask(pos);
return pr[pos] = {vec[0], vec[1]};
}
int find_best(int n) {
int mx = -1;
int mxpos = 0;
for (int i = 0; i < min(500, n); i++){
pair<int, int> pr = myask(i);
if (pr.first+pr.second == 0)
return i;
if (pr.first + pr.second > mx){
mx = pr.first + pr.second;
mxpos = i;
}
}
int lst = mxpos;
while(1){
int l = lst+1, r = n;
while(l < r){
int mid = (l+r)>>1;
pair<int, int> pr = myask(mid);
if (pr.first+pr.second == 0)
return mid;
if (pr != myask(lst))
r = mid; else
l = mid+1;
}
lst = l;
while(lst < n){
if (myask(lst).first + myask(lst).second == myask(mxpos).first+myask(mxpos).second)
break;
if (myask(lst).first + myask(lst).second == 0)
return lst;
++lst;
}
}
}
/**
8
3 2 3 1 3 2 3 3
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
8 ms |
376 KB |
Output is correct |
4 |
Correct |
8 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
392 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
400 KB |
Output is correct |
8 |
Correct |
3 ms |
400 KB |
Output is correct |
9 |
Correct |
7 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
376 KB |
Output is correct |
4 |
Correct |
8 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
400 KB |
Output is correct |
6 |
Correct |
2 ms |
308 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
7 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
396 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
896 KB |
Output is correct |
12 |
Correct |
4 ms |
440 KB |
Output is correct |
13 |
Correct |
12 ms |
1208 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
14 ms |
1092 KB |
Output is correct |
16 |
Partially correct |
36 ms |
1876 KB |
Partially correct - number of queries: 7154 |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Partially correct |
29 ms |
2132 KB |
Partially correct - number of queries: 8313 |
19 |
Correct |
3 ms |
320 KB |
Output is correct |
20 |
Correct |
10 ms |
988 KB |
Output is correct |
21 |
Correct |
14 ms |
1584 KB |
Output is correct |
22 |
Correct |
11 ms |
888 KB |
Output is correct |
23 |
Correct |
7 ms |
376 KB |
Output is correct |
24 |
Correct |
8 ms |
376 KB |
Output is correct |
25 |
Correct |
44 ms |
1632 KB |
Output is correct |
26 |
Correct |
34 ms |
1656 KB |
Output is correct |
27 |
Correct |
4 ms |
456 KB |
Output is correct |
28 |
Partially correct |
59 ms |
2040 KB |
Partially correct - number of queries: 7862 |
29 |
Partially correct |
51 ms |
1948 KB |
Partially correct - number of queries: 6074 |
30 |
Partially correct |
35 ms |
2052 KB |
Partially correct - number of queries: 8243 |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
9 ms |
1144 KB |
Output is correct |
33 |
Correct |
2 ms |
328 KB |
Output is correct |
34 |
Correct |
22 ms |
1320 KB |
Output is correct |
35 |
Correct |
8 ms |
632 KB |
Output is correct |
36 |
Correct |
21 ms |
1288 KB |
Output is correct |
37 |
Correct |
9 ms |
628 KB |
Output is correct |
38 |
Correct |
5 ms |
384 KB |
Output is correct |
39 |
Correct |
16 ms |
1648 KB |
Output is correct |
40 |
Partially correct |
73 ms |
2040 KB |
Partially correct - number of queries: 7125 |
41 |
Partially correct |
55 ms |
1656 KB |
Partially correct - number of queries: 5180 |
42 |
Partially correct |
41 ms |
1680 KB |
Partially correct - number of queries: 5180 |
43 |
Correct |
36 ms |
1728 KB |
Output is correct |
44 |
Correct |
18 ms |
1520 KB |
Output is correct |
45 |
Correct |
25 ms |
1400 KB |
Output is correct |
46 |
Correct |
5 ms |
384 KB |
Output is correct |
47 |
Correct |
32 ms |
1448 KB |
Output is correct |
48 |
Partially correct |
42 ms |
1784 KB |
Partially correct - number of queries: 6299 |
49 |
Correct |
10 ms |
760 KB |
Output is correct |
50 |
Partially correct |
32 ms |
2028 KB |
Partially correct - number of queries: 8297 |
51 |
Correct |
39 ms |
1528 KB |
Output is correct |
52 |
Correct |
4 ms |
404 KB |
Output is correct |
53 |
Correct |
4 ms |
636 KB |
Output is correct |
54 |
Correct |
15 ms |
1584 KB |
Output is correct |
55 |
Correct |
6 ms |
256 KB |
Output is correct |
56 |
Partially correct |
58 ms |
2052 KB |
Partially correct - number of queries: 8287 |
57 |
Partially correct |
50 ms |
1840 KB |
Partially correct - number of queries: 6186 |
58 |
Partially correct |
31 ms |
1808 KB |
Partially correct - number of queries: 6251 |
59 |
Partially correct |
19 ms |
1732 KB |
Partially correct - number of queries: 5179 |
60 |
Correct |
61 ms |
1576 KB |
Output is correct |
61 |
Correct |
4 ms |
512 KB |
Output is correct |
62 |
Correct |
3 ms |
392 KB |
Output is correct |
63 |
Correct |
6 ms |
640 KB |
Output is correct |
64 |
Correct |
3 ms |
452 KB |
Output is correct |
65 |
Correct |
3 ms |
452 KB |
Output is correct |
66 |
Correct |
11 ms |
376 KB |
Output is correct |
67 |
Correct |
3 ms |
520 KB |
Output is correct |
68 |
Correct |
3 ms |
388 KB |
Output is correct |
69 |
Correct |
10 ms |
376 KB |
Output is correct |
70 |
Correct |
5 ms |
376 KB |
Output is correct |
71 |
Partially correct |
66 ms |
2084 KB |
Partially correct - number of queries: 8311 |
72 |
Correct |
10 ms |
1272 KB |
Output is correct |
73 |
Partially correct |
42 ms |
2116 KB |
Partially correct - number of queries: 8197 |
74 |
Partially correct |
80 ms |
2084 KB |
Partially correct - number of queries: 8231 |
75 |
Correct |
9 ms |
760 KB |
Output is correct |
76 |
Partially correct |
71 ms |
2060 KB |
Partially correct - number of queries: 7114 |
77 |
Partially correct |
54 ms |
1844 KB |
Partially correct - number of queries: 6462 |
78 |
Correct |
9 ms |
1320 KB |
Output is correct |
79 |
Correct |
27 ms |
2040 KB |
Output is correct |
80 |
Partially correct |
41 ms |
2120 KB |
Partially correct - number of queries: 8365 |
81 |
Partially correct |
66 ms |
2088 KB |
Partially correct - number of queries: 8352 |
82 |
Partially correct |
29 ms |
2180 KB |
Partially correct - number of queries: 8268 |
83 |
Correct |
4 ms |
648 KB |
Output is correct |
84 |
Partially correct |
73 ms |
1992 KB |
Partially correct - number of queries: 6889 |
85 |
Partially correct |
39 ms |
1960 KB |
Partially correct - number of queries: 8345 |
86 |
Correct |
8 ms |
316 KB |
Output is correct |
87 |
Correct |
5 ms |
384 KB |
Output is correct |
88 |
Correct |
4 ms |
564 KB |
Output is correct |
89 |
Correct |
6 ms |
384 KB |
Output is correct |
90 |
Correct |
8 ms |
384 KB |
Output is correct |
91 |
Correct |
7 ms |
384 KB |
Output is correct |
92 |
Correct |
7 ms |
384 KB |
Output is correct |
93 |
Correct |
8 ms |
1152 KB |
Output is correct |
94 |
Correct |
10 ms |
1152 KB |
Output is correct |
95 |
Correct |
10 ms |
1144 KB |
Output is correct |
96 |
Correct |
11 ms |
1024 KB |
Output is correct |
97 |
Correct |
5 ms |
384 KB |
Output is correct |