# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
31573 |
2017-08-30T01:47:26 Z |
aome |
Hacker (BOI15_hac) |
C++14 |
|
86 ms |
49052 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, s[N], a[N], f[N], rmq[20][N], lg[N];
int gets(int l, int r) {
return s[r] - s[l - 1];
}
int getm(int l, int r) {
if (l > r) return 1e9;
int k = lg[r - l + 1];
return min(rmq[k][l], rmq[k][r - (1 << k) + 1]);
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 2; i <= n; ++i) lg[i] = lg[i >> 1] + 1;
for (int i = 1; i <= n; ++i) {
cin >> a[i], s[i] += s[i - 1] + a[i];
}
int val = (n + 1) / 2;
for (int i = 1; i <= n; ++i) {
rmq[0][i] = f[i] = gets(i, min(n, i + val - 1)) + gets(1, max(0, (i + val - 1) - n));
}
for (int i = 1; i < 20; ++i) {
for (int j = 1; j + (1 << i) - 1 <= n; ++j) {
rmq[i][j] = min(rmq[i - 1][j], rmq[i - 1][j + (1 << (i - 1))]);
}
}
int res = 0;
for (int i = 1; i <= n; ++i) {
int tmp = min(getm(max(1, i - val + 1), i), getm(n - max(0, val - i) + 1, n));
res = max(res, tmp);
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
49052 KB |
Output is correct |
2 |
Correct |
0 ms |
49052 KB |
Output is correct |
3 |
Correct |
0 ms |
49052 KB |
Output is correct |
4 |
Correct |
0 ms |
49052 KB |
Output is correct |
5 |
Correct |
0 ms |
49052 KB |
Output is correct |
6 |
Correct |
0 ms |
49052 KB |
Output is correct |
7 |
Correct |
0 ms |
49052 KB |
Output is correct |
8 |
Correct |
0 ms |
49052 KB |
Output is correct |
9 |
Correct |
0 ms |
49052 KB |
Output is correct |
10 |
Correct |
0 ms |
49052 KB |
Output is correct |
11 |
Correct |
0 ms |
49052 KB |
Output is correct |
12 |
Correct |
0 ms |
49052 KB |
Output is correct |
13 |
Correct |
0 ms |
49052 KB |
Output is correct |
14 |
Correct |
0 ms |
49052 KB |
Output is correct |
15 |
Correct |
0 ms |
49052 KB |
Output is correct |
16 |
Correct |
0 ms |
49052 KB |
Output is correct |
17 |
Correct |
0 ms |
49052 KB |
Output is correct |
18 |
Correct |
0 ms |
49052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
49052 KB |
Output is correct |
2 |
Correct |
0 ms |
49052 KB |
Output is correct |
3 |
Correct |
0 ms |
49052 KB |
Output is correct |
4 |
Correct |
0 ms |
49052 KB |
Output is correct |
5 |
Correct |
0 ms |
49052 KB |
Output is correct |
6 |
Correct |
0 ms |
49052 KB |
Output is correct |
7 |
Correct |
0 ms |
49052 KB |
Output is correct |
8 |
Correct |
0 ms |
49052 KB |
Output is correct |
9 |
Correct |
0 ms |
49052 KB |
Output is correct |
10 |
Correct |
0 ms |
49052 KB |
Output is correct |
11 |
Correct |
0 ms |
49052 KB |
Output is correct |
12 |
Correct |
0 ms |
49052 KB |
Output is correct |
13 |
Correct |
0 ms |
49052 KB |
Output is correct |
14 |
Correct |
0 ms |
49052 KB |
Output is correct |
15 |
Correct |
0 ms |
49052 KB |
Output is correct |
16 |
Correct |
0 ms |
49052 KB |
Output is correct |
17 |
Correct |
0 ms |
49052 KB |
Output is correct |
18 |
Correct |
0 ms |
49052 KB |
Output is correct |
19 |
Correct |
0 ms |
49052 KB |
Output is correct |
20 |
Correct |
0 ms |
49052 KB |
Output is correct |
21 |
Correct |
0 ms |
49052 KB |
Output is correct |
22 |
Correct |
0 ms |
49052 KB |
Output is correct |
23 |
Correct |
0 ms |
49052 KB |
Output is correct |
24 |
Correct |
0 ms |
49052 KB |
Output is correct |
25 |
Correct |
0 ms |
49052 KB |
Output is correct |
26 |
Correct |
0 ms |
49052 KB |
Output is correct |
27 |
Correct |
0 ms |
49052 KB |
Output is correct |
28 |
Correct |
0 ms |
49052 KB |
Output is correct |
29 |
Correct |
0 ms |
49052 KB |
Output is correct |
30 |
Correct |
0 ms |
49052 KB |
Output is correct |
31 |
Correct |
0 ms |
49052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
49052 KB |
Output is correct |
2 |
Correct |
0 ms |
49052 KB |
Output is correct |
3 |
Correct |
0 ms |
49052 KB |
Output is correct |
4 |
Correct |
13 ms |
49052 KB |
Output is correct |
5 |
Correct |
26 ms |
49052 KB |
Output is correct |
6 |
Correct |
39 ms |
49052 KB |
Output is correct |
7 |
Correct |
43 ms |
49052 KB |
Output is correct |
8 |
Correct |
73 ms |
49052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
49052 KB |
Output is correct |
2 |
Correct |
0 ms |
49052 KB |
Output is correct |
3 |
Correct |
0 ms |
49052 KB |
Output is correct |
4 |
Correct |
0 ms |
49052 KB |
Output is correct |
5 |
Correct |
0 ms |
49052 KB |
Output is correct |
6 |
Correct |
0 ms |
49052 KB |
Output is correct |
7 |
Correct |
0 ms |
49052 KB |
Output is correct |
8 |
Correct |
0 ms |
49052 KB |
Output is correct |
9 |
Correct |
0 ms |
49052 KB |
Output is correct |
10 |
Correct |
0 ms |
49052 KB |
Output is correct |
11 |
Correct |
0 ms |
49052 KB |
Output is correct |
12 |
Correct |
0 ms |
49052 KB |
Output is correct |
13 |
Correct |
0 ms |
49052 KB |
Output is correct |
14 |
Correct |
0 ms |
49052 KB |
Output is correct |
15 |
Correct |
0 ms |
49052 KB |
Output is correct |
16 |
Correct |
0 ms |
49052 KB |
Output is correct |
17 |
Correct |
0 ms |
49052 KB |
Output is correct |
18 |
Correct |
0 ms |
49052 KB |
Output is correct |
19 |
Correct |
0 ms |
49052 KB |
Output is correct |
20 |
Correct |
0 ms |
49052 KB |
Output is correct |
21 |
Correct |
0 ms |
49052 KB |
Output is correct |
22 |
Correct |
0 ms |
49052 KB |
Output is correct |
23 |
Correct |
0 ms |
49052 KB |
Output is correct |
24 |
Correct |
0 ms |
49052 KB |
Output is correct |
25 |
Correct |
0 ms |
49052 KB |
Output is correct |
26 |
Correct |
0 ms |
49052 KB |
Output is correct |
27 |
Correct |
0 ms |
49052 KB |
Output is correct |
28 |
Correct |
0 ms |
49052 KB |
Output is correct |
29 |
Correct |
0 ms |
49052 KB |
Output is correct |
30 |
Correct |
0 ms |
49052 KB |
Output is correct |
31 |
Correct |
0 ms |
49052 KB |
Output is correct |
32 |
Correct |
0 ms |
49052 KB |
Output is correct |
33 |
Correct |
0 ms |
49052 KB |
Output is correct |
34 |
Correct |
0 ms |
49052 KB |
Output is correct |
35 |
Correct |
13 ms |
49052 KB |
Output is correct |
36 |
Correct |
26 ms |
49052 KB |
Output is correct |
37 |
Correct |
39 ms |
49052 KB |
Output is correct |
38 |
Correct |
43 ms |
49052 KB |
Output is correct |
39 |
Correct |
73 ms |
49052 KB |
Output is correct |
40 |
Correct |
0 ms |
49052 KB |
Output is correct |
41 |
Correct |
3 ms |
49052 KB |
Output is correct |
42 |
Correct |
3 ms |
49052 KB |
Output is correct |
43 |
Correct |
33 ms |
49052 KB |
Output is correct |
44 |
Correct |
79 ms |
49052 KB |
Output is correct |
45 |
Correct |
9 ms |
49052 KB |
Output is correct |
46 |
Correct |
46 ms |
49052 KB |
Output is correct |
47 |
Correct |
69 ms |
49052 KB |
Output is correct |
48 |
Correct |
86 ms |
49052 KB |
Output is correct |
49 |
Correct |
69 ms |
49052 KB |
Output is correct |
50 |
Correct |
73 ms |
49052 KB |
Output is correct |