#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5+5;
#define ll long long
ll A[MXN], P[MXN], n;
ll sum(int i,int j){return (i<=j?P[j]-P[i-1]:0);}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
ll ans = 0;
for(int i = 1;i<=n;i++){
cin >> A[i]; P[i] = P[i-1]+A[i];
}
for(int i = 1;i<=n;i++){
for(int j = i;j<=n;j++){ // [i,j] [j+1,k] [k+1,n]+[1,i-1]
for(int k = j+1;k<=n;k++){
ans = max(ans,min({sum(i,j),sum(j+1,k),sum(k+1,n)+sum(1,i-1)}));
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
19 ms |
328 KB |
Output is correct |
12 |
Correct |
18 ms |
340 KB |
Output is correct |
13 |
Correct |
21 ms |
340 KB |
Output is correct |
14 |
Correct |
18 ms |
212 KB |
Output is correct |
15 |
Correct |
18 ms |
332 KB |
Output is correct |
16 |
Correct |
18 ms |
340 KB |
Output is correct |
17 |
Correct |
18 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
352 KB |
Output is correct |
19 |
Correct |
18 ms |
332 KB |
Output is correct |
20 |
Correct |
18 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
19 ms |
328 KB |
Output is correct |
12 |
Correct |
18 ms |
340 KB |
Output is correct |
13 |
Correct |
21 ms |
340 KB |
Output is correct |
14 |
Correct |
18 ms |
212 KB |
Output is correct |
15 |
Correct |
18 ms |
332 KB |
Output is correct |
16 |
Correct |
18 ms |
340 KB |
Output is correct |
17 |
Correct |
18 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
352 KB |
Output is correct |
19 |
Correct |
18 ms |
332 KB |
Output is correct |
20 |
Correct |
18 ms |
340 KB |
Output is correct |
21 |
Execution timed out |
2045 ms |
400 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
19 ms |
328 KB |
Output is correct |
12 |
Correct |
18 ms |
340 KB |
Output is correct |
13 |
Correct |
21 ms |
340 KB |
Output is correct |
14 |
Correct |
18 ms |
212 KB |
Output is correct |
15 |
Correct |
18 ms |
332 KB |
Output is correct |
16 |
Correct |
18 ms |
340 KB |
Output is correct |
17 |
Correct |
18 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
352 KB |
Output is correct |
19 |
Correct |
18 ms |
332 KB |
Output is correct |
20 |
Correct |
18 ms |
340 KB |
Output is correct |
21 |
Execution timed out |
2045 ms |
400 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |