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;
long long n,sum,a[1000500];
vector<long long>v;
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
for(int i=n;i<2*n;i++)a[i]=a[i-n];
long long sum1=a[0],l=0,r=0,mx=n/2;
while(true)
{
if(r-l+1>mx)
{
sum1-=a[l];
l++;
}
if(l==n)break;
if(r-l+1==mx)v.push_back(sum-sum1);
r++;
sum1+=a[r];
}
sort(v.begin(),v.end());
cout<<v[(v.size()/2)+(n%2)];
}
# | 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... |