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 MAX_N = 5e5;
int n, v[MAX_N + 1], sp[MAX_N + 1];
int sum( int l, int r ) {
if ( l > n )
l -= n;
if ( r > n )
r -= n;
if ( l > r )
return sp[n] - sp[l - 1] + sp[r];
return sp[r] - sp[l - 1];
}
int main() {
cin >> n;
for ( int i = 1; i <= n; i++ ) {
cin >> v[i];
sp[i] = sp[i - 1] + v[i];
}
int maxx = 0;
for ( int i = 1; i <= n; i++ ) {
int minn = 1e9;
for ( int l = 0; l < (n + 1) / 2; l++ )
minn = min( minn, sum( i + l, i + l + (n + 1) / 2 - 1 ) );
maxx = max( maxx, minn );
}
cout << maxx;
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... |