#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 4000005
#define ff first
#define ss second
#define pb push_back
#define sz(s) (int)s.size()
#define rep(c, a, b) for(c = a; c <= b; c++)
ll n, t, v[N], mx, sum, l, r, answer;
map <ll,ll> vis;
int main () {
ios::sync_with_stdio(0);cin.tie(0);
cin >> n;
for(int i =1;i<=n;i++) {
cin >> v[i];
}
for(int i = 1; i <= n; i++) {
l = i;
r = i;
t = 1;
sum = 0;
while(t <= (n + 1) / 2) {
t++;
sum += v[r];
r--;
if(!r) r = n;
}
t = 1;
mx = sum;
while(t < (n + 1) / 2) {
t++;
l++;
sum -= v[r];
sum += v[l];
r++;
if(l == n + 1) l = 1;
if(r == n + 1) r = 1;
mx = min(mx,sum);
}
answer = max(answer,mx);
}
cout << answer << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |