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;
using ll = long long;
int N;
int A[500069];
vector<int> W[500069];
int main() {
ios::sync_with_stdio(0);
cin >> N;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
int k = (N + 1) / 2;
int b = k;
int sum = 0;
for (int i = 0; i < b; i++) sum += A[i];
for (int a = 0; a < N; a++) {
W[a].push_back(sum);
W[b].push_back(-sum);
sum = sum + A[b] - A[a];
b = (b + 1) % N;
}
multiset<int> E;
for (int i = N - k; i < N; i++) {
for (int a : W[i]) if(a > 0)
E.insert(a);
}
int mx = 0;
for (int i = 0; i < N; i++) {
for (int a : W[i]) if(a > 0)
E.insert(a);
for (int a : W[i]) if(a < 0)
E.erase(E.find(-a));
mx = max(mx, *E.begin());
}
cout << mx << '\n';
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... |