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;
const int N = 500*1000+5;
int a[N];
int main(){
ios_base::sync_with_stdio(false);
int n;
cin>>n;
long long all = 0;
for(int i = 1;i<=n;i++) {
cin>>a[i];
all+=a[i];
}
long long ans = 0;
for(int i = 1;i<=n;i++){
long long mx = 0;
for(int j = 1;j<=n;j++){
int jj = j;
int qn = 0;
long long cur = 0;
while(1){
if(jj == i) break;
cur+=a[jj];
qn++;
if(qn == n/2) break;
jj++;
if(jj>n) jj = 1;
}
mx = max(mx,cur);
}
ans = max(ans,all-mx);
}
cout<<ans<<endl;
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... |