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+1)/2; ++i){
cur+=v[i];
}
msa.push_back(cur);
for(int i = 0; i < n-1; ++i){
cur-=v[i];
cur+=v[(i+((n+1)/2))%n];
msa.push_back(cur);
}
map<int,int> S;
for(int i = 0; i < (n+1)/2; ++i){
S[msa[i]]++;
}
int ans = S.begin()->first;
for(int i = 0; i < n-1; ++i){
S[msa[i]]--;
if(!S[msa[i]])S.erase(msa[i]);
S[msa[(i+((n+1)/2))%n]]++;
ans = max(ans,S.begin()->first);
}
cout << 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... |