#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n; cin >> n;
vector<int> v(n*2);
for (int i = 0; i < n; i++) cin >> v[i];
for (int i = 0; i < n; i++) v[i+n]=v[i];
int suml=0,sumr=0;
int mx=0;
int l1=0, l2=(n+2)/2;
int r1=(n-1)/2, r2=n;
for (int i = 0; i <= n; i++)
{
if(i<=r1) suml+=v[i];
if(i>=l2) sumr+=v[i];
}
mx=max(mx,min(suml,sumr));
for (int i = 1; i < n; i++)
{
suml-=v[l1];
sumr-=v[l2];
l1++;
l2++;
r1++;
r2++;
suml+=v[r1];
sumr+=v[r2];
mx=max(mx,min(suml,sumr));
}
cout << mx;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
388 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |