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;
#define int long long
signed main() {
int n ;
cin>>n;
vector<int> v(n);
vector<int> pref(2 * n);
for(int i = 0 ;i < n ; i++)
{
cin>>v[i];
pref[i] = v[i];
if(i)
pref[i]+=pref[i - 1];
}
for(int i = n ; i < 2 * n; i++)
{
pref[i] = pref[i - 1] + v[i - n];
}
int best = 0;
for(int shift = 0 ; shift < n ; shift++)
{
int ans = LLONG_MAX;
for(int i = 1 + n/2 ; i <= n ; i++)
{
int j = ((i + shift) % n);
int k = (j + (n+1)/2 - 1);
ans = min(ans , pref[k] - (j ? pref[j - 1] : 0));
}
best = max(best , ans);
}
cout<<best<<'\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... |