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 ll long long
#define ar array
const int mxN=5e5;
int n, a[mxN], p[mxN+1];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i=0; i<n; ++i)
cin >> a[i];
int ans=0;
for (int rep=0; rep<n; ++rep) {
for (int i=0; i<n; ++i)
p[i+1]=p[i]+a[i];
int mx=0;
for (int i=1; i<n; ++i) {
int cur=0;
for (int j=1; j+n/2-1<n; ++j) {
int j2=j+n/2-1;
if (i-j<j&&j2-i<n-j2)
cur=max(cur, p[j+n/2]-p[j]);
}
mx=max(mx, cur);
}
ans=max(ans, p[n]-mx);
rotate(a, a+1, a+n);
}
cout << ans;
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... |