#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline void fastio();
ll n, arr[200001], sum[200001], ans, mx;
int main() {
fastio();
cin >> n;
for (ll i = 0; i < n; i++) {
cin >> arr[i];
arr[i + n] = arr[i];
mx = max(mx, arr[i]);
}
for (ll i = 0; i < 2 * n; i++) {
sum[i + 1] = sum[i] + arr[i];
}
for (ll i = 0; i < n; i++) {
ll s = 0, e = sum[2 * n];
while (s - e + 1 < 0) {
ll m = (s + e) / 2;
bool chk = true;
for (ll j = 0, loc = i; j < 3; j++) {
loc = lower_bound(sum, sum + 2 * n + 1, m + sum[loc]) - sum;
if (loc > i + n) {
chk = false;
break;
}
}
if (chk) {
s = m;
} else {
e = m;
}
}
ans = max(ans, s);
}
cout << ans << '\n';
}
inline void fastio() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2504 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2504 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2504 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
16 ms |
2652 KB |
Output is correct |
22 |
Correct |
17 ms |
2520 KB |
Output is correct |
23 |
Correct |
16 ms |
2680 KB |
Output is correct |
24 |
Correct |
16 ms |
2680 KB |
Output is correct |
25 |
Correct |
16 ms |
2648 KB |
Output is correct |
26 |
Correct |
21 ms |
2652 KB |
Output is correct |
27 |
Correct |
20 ms |
2652 KB |
Output is correct |
28 |
Correct |
21 ms |
2652 KB |
Output is correct |
29 |
Correct |
21 ms |
2648 KB |
Output is correct |
30 |
Correct |
24 ms |
2720 KB |
Output is correct |
31 |
Correct |
10 ms |
2652 KB |
Output is correct |
32 |
Correct |
11 ms |
2652 KB |
Output is correct |
33 |
Correct |
10 ms |
2652 KB |
Output is correct |
34 |
Correct |
10 ms |
2652 KB |
Output is correct |
35 |
Correct |
10 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2504 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
16 ms |
2652 KB |
Output is correct |
22 |
Correct |
17 ms |
2520 KB |
Output is correct |
23 |
Correct |
16 ms |
2680 KB |
Output is correct |
24 |
Correct |
16 ms |
2680 KB |
Output is correct |
25 |
Correct |
16 ms |
2648 KB |
Output is correct |
26 |
Correct |
21 ms |
2652 KB |
Output is correct |
27 |
Correct |
20 ms |
2652 KB |
Output is correct |
28 |
Correct |
21 ms |
2652 KB |
Output is correct |
29 |
Correct |
21 ms |
2648 KB |
Output is correct |
30 |
Correct |
24 ms |
2720 KB |
Output is correct |
31 |
Correct |
10 ms |
2652 KB |
Output is correct |
32 |
Correct |
11 ms |
2652 KB |
Output is correct |
33 |
Correct |
10 ms |
2652 KB |
Output is correct |
34 |
Correct |
10 ms |
2652 KB |
Output is correct |
35 |
Correct |
10 ms |
2652 KB |
Output is correct |
36 |
Correct |
320 ms |
4444 KB |
Output is correct |
37 |
Correct |
333 ms |
4444 KB |
Output is correct |
38 |
Correct |
318 ms |
4532 KB |
Output is correct |
39 |
Correct |
327 ms |
4440 KB |
Output is correct |
40 |
Correct |
349 ms |
4444 KB |
Output is correct |
41 |
Correct |
344 ms |
4692 KB |
Output is correct |
42 |
Correct |
319 ms |
4532 KB |
Output is correct |
43 |
Correct |
328 ms |
4532 KB |
Output is correct |
44 |
Correct |
321 ms |
4440 KB |
Output is correct |
45 |
Correct |
329 ms |
4688 KB |
Output is correct |
46 |
Correct |
160 ms |
3672 KB |
Output is correct |
47 |
Correct |
160 ms |
3552 KB |
Output is correct |
48 |
Correct |
162 ms |
3676 KB |
Output is correct |