#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)];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |