이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
multiset<int> minn;
for ( int l = 0; l < (n + 1) / 2; l++ )
minn.insert( sum( 1 + l, 1 + l + (n + 1) / 2 - 1 ) );
for ( int i = 1; i <= n; i++ ) {
maxx = max( maxx, *minn.begin() );
int sin = sum( i + (n + 1) / 2, i + (n + 1) / 2 + (n + 1) / 2 - 1 );
int sout = sum( i, i + (n + 1) / 2 - 1 );
minn.insert( sin );
minn.erase( minn.lower_bound( sout ) );
}
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... |