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 n,sum=0,res=0,a[1000005];
multiset<int> s;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
a[i+n]=a[i];
sum+=a[i];
}
for(int i=1;i<=2*n;i++)
a[i]+=a[i-1];
int k=n/2;
for(int i=k;i<n;i++)
s.insert(a[i]-a[i-k]);
for(int i=1;i<=n;i++)
{
s.erase(s.find(a[i+k-1]-a[i-1]));
s.insert(a[i+n-1]-a[i+n-1-k]);
res=max(res,sum-*s.rbegin());
}
cout<<res;
}
# | 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... |