#include "prize.h"
#include <bits/stdc++.h>
#define sc second
#define fr first
#define mk make_pair
#define pb push_back
using namespace std;
const int N = (1e6 + 5);
const int inf = (1e9 + 7);
vector <int> res[N];
int mx,cur;
int find_best(int n) {
for (int i = 0; i < min(n,500); i ++) {
if (res[i].size() == 0)
res[i] = ask(i);
int s = res[i][0] + res[i][1];
if (!s) return i;
if (s >= mx) mx = s,cur = i;
}
while(1) {
if (res[cur].size() == 0)
res[cur] = ask(cur);
if (res[cur][0] + res[cur][1] == 0) return cur;
if (res[cur][0] + res[cur][1] != mx) {
cur ++;
continue;
}
int lf = res[cur][0];
int rt = res[cur][1];
int l = cur,r = min(cur + 700,n - 1);
if (res[r].size() == 0)
res[r] = ask(r);
if (res[r][0] + res[r][1] == 0) return r;
if (res[l] == res[r]) {
cur = r + 1;
continue;
}
while (r - l > 1) {
int m = (r + l) >> 1;
if (res[m].size() == 0)
res[m] = ask(m);
if (res[m][0] + res[m][1] == 0) return m;
if (res[m][0] == lf && res[m][1] == rt) l = m;
else r = m;
}
if (res[r].size() == 0)
res[r] = ask(r);
if (res[r][0] + res[r][1] == 0) return r;
if (res[r][0] == lf && res[r][1] == rt) l = r;
cur = l + 1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
23720 KB |
Output is correct |
2 |
Correct |
28 ms |
23880 KB |
Output is correct |
3 |
Correct |
29 ms |
23820 KB |
Output is correct |
4 |
Correct |
34 ms |
23908 KB |
Output is correct |
5 |
Correct |
31 ms |
23800 KB |
Output is correct |
6 |
Correct |
23 ms |
23800 KB |
Output is correct |
7 |
Correct |
32 ms |
23720 KB |
Output is correct |
8 |
Correct |
30 ms |
23848 KB |
Output is correct |
9 |
Correct |
28 ms |
23816 KB |
Output is correct |
10 |
Correct |
29 ms |
23824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
23804 KB |
Output is correct |
2 |
Correct |
29 ms |
23800 KB |
Output is correct |
3 |
Correct |
30 ms |
23800 KB |
Output is correct |
4 |
Correct |
33 ms |
23800 KB |
Output is correct |
5 |
Correct |
31 ms |
23800 KB |
Output is correct |
6 |
Correct |
23 ms |
23672 KB |
Output is correct |
7 |
Correct |
31 ms |
23720 KB |
Output is correct |
8 |
Correct |
28 ms |
23812 KB |
Output is correct |
9 |
Correct |
30 ms |
23800 KB |
Output is correct |
10 |
Correct |
34 ms |
23748 KB |
Output is correct |
11 |
Correct |
28 ms |
23824 KB |
Output is correct |
12 |
Correct |
26 ms |
23816 KB |
Output is correct |
13 |
Correct |
34 ms |
23804 KB |
Output is correct |
14 |
Correct |
32 ms |
23800 KB |
Output is correct |
15 |
Correct |
34 ms |
23800 KB |
Output is correct |
16 |
Correct |
54 ms |
23908 KB |
Output is correct |
17 |
Correct |
26 ms |
23804 KB |
Output is correct |
18 |
Partially correct |
74 ms |
23928 KB |
Partially correct - number of queries: 5716 |
19 |
Correct |
27 ms |
23800 KB |
Output is correct |
20 |
Correct |
41 ms |
23848 KB |
Output is correct |
21 |
Correct |
35 ms |
23980 KB |
Output is correct |
22 |
Correct |
33 ms |
23800 KB |
Output is correct |
23 |
Correct |
27 ms |
23816 KB |
Output is correct |
24 |
Correct |
29 ms |
23820 KB |
Output is correct |
25 |
Correct |
55 ms |
24004 KB |
Output is correct |
26 |
Correct |
59 ms |
23892 KB |
Output is correct |
27 |
Correct |
27 ms |
23824 KB |
Output is correct |
28 |
Partially correct |
52 ms |
24020 KB |
Partially correct - number of queries: 5641 |
29 |
Correct |
62 ms |
23952 KB |
Output is correct |
30 |
Partially correct |
60 ms |
23976 KB |
Partially correct - number of queries: 5713 |
31 |
Correct |
27 ms |
23720 KB |
Output is correct |
32 |
Correct |
29 ms |
23916 KB |
Output is correct |
33 |
Correct |
23 ms |
23800 KB |
Output is correct |
34 |
Correct |
46 ms |
23804 KB |
Output is correct |
35 |
Correct |
34 ms |
23800 KB |
Output is correct |
36 |
Correct |
32 ms |
23840 KB |
Output is correct |
37 |
Correct |
31 ms |
23800 KB |
Output is correct |
38 |
Correct |
29 ms |
23804 KB |
Output is correct |
39 |
Correct |
38 ms |
23884 KB |
Output is correct |
40 |
Partially correct |
81 ms |
23940 KB |
Partially correct - number of queries: 5123 |
41 |
Correct |
57 ms |
23892 KB |
Output is correct |
42 |
Correct |
57 ms |
23800 KB |
Output is correct |
43 |
Correct |
51 ms |
23944 KB |
Output is correct |
44 |
Correct |
50 ms |
23928 KB |
Output is correct |
45 |
Correct |
48 ms |
23864 KB |
Output is correct |
46 |
Correct |
26 ms |
23816 KB |
Output is correct |
47 |
Correct |
51 ms |
23928 KB |
Output is correct |
48 |
Correct |
44 ms |
23936 KB |
Output is correct |
49 |
Correct |
33 ms |
23720 KB |
Output is correct |
50 |
Partially correct |
52 ms |
23980 KB |
Partially correct - number of queries: 5721 |
51 |
Correct |
36 ms |
24016 KB |
Output is correct |
52 |
Correct |
28 ms |
23800 KB |
Output is correct |
53 |
Correct |
35 ms |
23800 KB |
Output is correct |
54 |
Correct |
37 ms |
24012 KB |
Output is correct |
55 |
Correct |
25 ms |
23892 KB |
Output is correct |
56 |
Partially correct |
81 ms |
23928 KB |
Partially correct - number of queries: 5714 |
57 |
Correct |
59 ms |
23940 KB |
Output is correct |
58 |
Correct |
44 ms |
23924 KB |
Output is correct |
59 |
Correct |
57 ms |
23888 KB |
Output is correct |
60 |
Correct |
41 ms |
23908 KB |
Output is correct |
61 |
Correct |
34 ms |
23800 KB |
Output is correct |
62 |
Correct |
28 ms |
23800 KB |
Output is correct |
63 |
Correct |
29 ms |
23952 KB |
Output is correct |
64 |
Correct |
28 ms |
23824 KB |
Output is correct |
65 |
Correct |
37 ms |
23808 KB |
Output is correct |
66 |
Correct |
38 ms |
23804 KB |
Output is correct |
67 |
Correct |
34 ms |
23800 KB |
Output is correct |
68 |
Correct |
27 ms |
23800 KB |
Output is correct |
69 |
Correct |
31 ms |
23852 KB |
Output is correct |
70 |
Correct |
34 ms |
23792 KB |
Output is correct |
71 |
Partially correct |
50 ms |
24080 KB |
Partially correct - number of queries: 5318 |
72 |
Correct |
36 ms |
23800 KB |
Output is correct |
73 |
Partially correct |
77 ms |
23928 KB |
Partially correct - number of queries: 5255 |
74 |
Partially correct |
51 ms |
24072 KB |
Partially correct - number of queries: 5282 |
75 |
Correct |
38 ms |
23800 KB |
Output is correct |
76 |
Correct |
66 ms |
23944 KB |
Output is correct |
77 |
Partially correct |
89 ms |
23976 KB |
Partially correct - number of queries: 5748 |
78 |
Correct |
40 ms |
23800 KB |
Output is correct |
79 |
Correct |
53 ms |
23800 KB |
Output is correct |
80 |
Partially correct |
83 ms |
23868 KB |
Partially correct - number of queries: 5692 |
81 |
Partially correct |
77 ms |
23980 KB |
Partially correct - number of queries: 5741 |
82 |
Partially correct |
99 ms |
23932 KB |
Partially correct - number of queries: 5686 |
83 |
Correct |
36 ms |
23800 KB |
Output is correct |
84 |
Correct |
75 ms |
24000 KB |
Output is correct |
85 |
Partially correct |
53 ms |
24008 KB |
Partially correct - number of queries: 5722 |
86 |
Correct |
29 ms |
23884 KB |
Output is correct |
87 |
Correct |
35 ms |
23800 KB |
Output is correct |
88 |
Correct |
34 ms |
23928 KB |
Output is correct |
89 |
Correct |
36 ms |
23800 KB |
Output is correct |
90 |
Correct |
30 ms |
23804 KB |
Output is correct |
91 |
Correct |
35 ms |
23800 KB |
Output is correct |
92 |
Correct |
29 ms |
23800 KB |
Output is correct |
93 |
Correct |
37 ms |
23800 KB |
Output is correct |
94 |
Correct |
37 ms |
23800 KB |
Output is correct |
95 |
Correct |
43 ms |
23804 KB |
Output is correct |
96 |
Correct |
37 ms |
23928 KB |
Output is correct |
97 |
Correct |
35 ms |
23800 KB |
Output is correct |