This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*********************ALLAH HO AKBAR***********************/
/************HAZRAT MUHAMMAD (Peace be upon him)***********/
#include <bits/stdc++.h>
using namespace std;
#define int long long
int const N=1e6+5;
int pre[N];
int arr[N];
int n;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
int sm=0;
for (int i = 1; i <=n; ++i){
cin>>arr[i];
sm+=arr[i];
}
for (int i = 1; i <=n; ++i)
arr[i+n]=arr[i];
int k=(n/2)+(n%2);
for (int i = 1; i <=2*n; ++i)
pre[i]=pre[i-1]+arr[i];
vector<pair<int,int>> v;
for (int i = 1; i <=n; ++i)
{
int chunk=pre[(i+k)-1]-pre[i-1];
int chunk2=sm-chunk;
if(chunk>=chunk2)
v.push_back({chunk-chunk2,chunk});
}
sort(v.begin(), v.end());
cout<<v[0].second<<endl;
return 0;
}
# | 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... |