This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
int n;
cin>>n;
vector<ll> v(n);
for(auto &i:v) cin>>i;
vector<ll> p(n);
p = v;
for(int i=1;i<n;i++) p[i] += p[i-1];
auto getSum = [&](int l,int r){
if(l <= r) return p[r] - (l ? p[l-1] : 0);
return p[n-1] - p[l - 1] + p[r];
};
ll ans = 0;
for(int i=0;i<n;i++){
int x = i+((n+1)/2)-1;
x %= n;
ll ans1 = getSum(i,x);
x = i-((n+1)/2)+1;
x += n;
x %= n;
ll ans2 = getSum(x,i);
ans = max(ans , min(ans1 , ans2));
}
cout<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
# | 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... |