#include "bits/stdc++.h"
using namespace std;
int n;
int a[500010];
long long p[500010];
const long long inf = 1e17;
int main(int argc, char const *argv[])
{
ios_base :: sync_with_stdio (false);
cin.tie (0);
cin >> n;
for(int i = 0; i < n; i++) {
cin >> a[i];
}
int move = (n + 1) >> 1;
long long sum = 0;
for(int i = 0; i < move; i++) {
sum += a[i];
}
for(int i = 0; i < n; i++) {
p[i] = sum;
sum -= a[i];
sum += a[(i + move) % n];
}
long long ans = 0;
for(int i = 0; i < n; i++) {
long long opt = inf;
for(int j = 0; j < move; j++) {
opt = min(opt, p[(i + j) % n]);
}
ans = max(ans, opt);
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
2 ms |
500 KB |
Output is correct |
7 |
Correct |
2 ms |
536 KB |
Output is correct |
8 |
Correct |
2 ms |
544 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
700 KB |
Output is correct |
11 |
Correct |
2 ms |
800 KB |
Output is correct |
12 |
Correct |
2 ms |
800 KB |
Output is correct |
13 |
Correct |
2 ms |
800 KB |
Output is correct |
14 |
Correct |
2 ms |
800 KB |
Output is correct |
15 |
Correct |
2 ms |
800 KB |
Output is correct |
16 |
Correct |
2 ms |
800 KB |
Output is correct |
17 |
Correct |
2 ms |
800 KB |
Output is correct |
18 |
Correct |
2 ms |
800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
2 ms |
500 KB |
Output is correct |
7 |
Correct |
2 ms |
536 KB |
Output is correct |
8 |
Correct |
2 ms |
544 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
700 KB |
Output is correct |
11 |
Correct |
2 ms |
800 KB |
Output is correct |
12 |
Correct |
2 ms |
800 KB |
Output is correct |
13 |
Correct |
2 ms |
800 KB |
Output is correct |
14 |
Correct |
2 ms |
800 KB |
Output is correct |
15 |
Correct |
2 ms |
800 KB |
Output is correct |
16 |
Correct |
2 ms |
800 KB |
Output is correct |
17 |
Correct |
2 ms |
800 KB |
Output is correct |
18 |
Correct |
2 ms |
800 KB |
Output is correct |
19 |
Correct |
3 ms |
800 KB |
Output is correct |
20 |
Correct |
4 ms |
800 KB |
Output is correct |
21 |
Correct |
3 ms |
800 KB |
Output is correct |
22 |
Correct |
18 ms |
800 KB |
Output is correct |
23 |
Correct |
53 ms |
828 KB |
Output is correct |
24 |
Correct |
18 ms |
828 KB |
Output is correct |
25 |
Correct |
46 ms |
848 KB |
Output is correct |
26 |
Correct |
47 ms |
1016 KB |
Output is correct |
27 |
Correct |
2 ms |
1016 KB |
Output is correct |
28 |
Correct |
2 ms |
1016 KB |
Output is correct |
29 |
Correct |
2 ms |
1016 KB |
Output is correct |
30 |
Correct |
47 ms |
1016 KB |
Output is correct |
31 |
Correct |
49 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1016 KB |
Output is correct |
2 |
Correct |
2 ms |
1016 KB |
Output is correct |
3 |
Correct |
47 ms |
1016 KB |
Output is correct |
4 |
Execution timed out |
1073 ms |
2268 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
500 KB |
Output is correct |
6 |
Correct |
2 ms |
500 KB |
Output is correct |
7 |
Correct |
2 ms |
536 KB |
Output is correct |
8 |
Correct |
2 ms |
544 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
700 KB |
Output is correct |
11 |
Correct |
2 ms |
800 KB |
Output is correct |
12 |
Correct |
2 ms |
800 KB |
Output is correct |
13 |
Correct |
2 ms |
800 KB |
Output is correct |
14 |
Correct |
2 ms |
800 KB |
Output is correct |
15 |
Correct |
2 ms |
800 KB |
Output is correct |
16 |
Correct |
2 ms |
800 KB |
Output is correct |
17 |
Correct |
2 ms |
800 KB |
Output is correct |
18 |
Correct |
2 ms |
800 KB |
Output is correct |
19 |
Correct |
3 ms |
800 KB |
Output is correct |
20 |
Correct |
4 ms |
800 KB |
Output is correct |
21 |
Correct |
3 ms |
800 KB |
Output is correct |
22 |
Correct |
18 ms |
800 KB |
Output is correct |
23 |
Correct |
53 ms |
828 KB |
Output is correct |
24 |
Correct |
18 ms |
828 KB |
Output is correct |
25 |
Correct |
46 ms |
848 KB |
Output is correct |
26 |
Correct |
47 ms |
1016 KB |
Output is correct |
27 |
Correct |
2 ms |
1016 KB |
Output is correct |
28 |
Correct |
2 ms |
1016 KB |
Output is correct |
29 |
Correct |
2 ms |
1016 KB |
Output is correct |
30 |
Correct |
47 ms |
1016 KB |
Output is correct |
31 |
Correct |
49 ms |
1016 KB |
Output is correct |
32 |
Correct |
2 ms |
1016 KB |
Output is correct |
33 |
Correct |
2 ms |
1016 KB |
Output is correct |
34 |
Correct |
47 ms |
1016 KB |
Output is correct |
35 |
Execution timed out |
1073 ms |
2268 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |