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;
int main(){
int n; cin >> n;
vector<int> v(n), msa;
for(auto &x : v)cin >> x;
int cur = 0;
for(int i = 0; i < n/2; ++i){
cur+=v[i];
}
msa.push_back(cur);
int tot = v[n-1];
for(int i = 0; i < n-1; ++i){
tot+=v[i];
cur-=v[i];
cur+=v[(i+(n/2))%n];
msa.push_back(cur);
}
set<int> S;
for(int i = 0; i < n/2; ++ i){
S.insert(msa[i]);
}
int ans = *S.rbegin();
for(int i = 0; i < n-1; ++i){
S.erase(msa[i]);
S.insert(msa[(i+(n/2))%n]);
ans = min(ans,*S.rbegin());
}
cout << tot-ans << "\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... |