#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int x[(2*n)+1];
for(int i=1; i<=n; ++i) {
cin >> x[i];
x[i+n]=x[i];
}
x[0]=0;
for(int i=2; i<=(2*n); ++i) x[i]+=x[i-1];
int k=(n+1)/2, ans=0;
multiset<int> window;
window.clear();
for(int i=1; i<=(n+k); ++i) {
window.insert(x[i+k-1]-x[i-1]);
if(i>k) {
window.erase(window.find(x[i-1]-x[i-1-k]));
ans = max(ans,*window.begin());
}
}
cout << ans << 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... |