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;
const int maxn = 1e5+10;
int vet[maxn], sum[maxn];
int main(){
int n, resp=-1;
cin >> n;
for(int i=1; i<=n; i++){
cin >> vet[i];
sum[i]=vet[i]+sum[i-1];
}
int k = n/2;
if(n%2==1)k++;
for(int i=1; i<=n; i++){
int left, right;
if(i>=k)left=sum[i] - sum[i-k];
else left=sum[i] + sum[n] - sum[n-(k-i)];
if(i+k-1<=n)right = sum[k+i-1] - sum[i-1];
else{
right = sum[n]-sum[i-1] + sum[k-(n-i+1)];
}
int u = min(left, right);
resp=max(resp, u);
}
cout << resp << endl;
}
# | 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... |