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;
#define MAX 200007
#define int long long
main(){
int n; cin >> n;
int count = (n+1)/2;
int arr[2*n];
for (int x = 0; x < n; x++) cin >> arr[x];
for (int x = 0; x < n; x++) arr[n + x] = arr[x];
int psum[2*n];
psum[0] = arr[0];
for (int x = 1; x < 2*n; x++) psum[x] = psum[x-1] + arr[x];
#define rq(a, b) ((a==0) ? psum[b] : psum[b] - psum[a-1])
int hmm[2*n]; memset(hmm, 63, sizeof(hmm));
int sums[2*n];
for (int x = 0; x < 2*n; x++){
int sum = rq(x, x+count-1);
sums[x] = sum;
}
multiset<int> ms;
for (int x = 0; x < count; x++){
ms.insert(sums[x]);
}
memset(hmm, -63, sizeof(hmm));
hmm[0] = *ms.begin();
for (int x = 1; x < n; x++){
ms.insert(sums[count+x-1]);
ms.erase(ms.find(sums[x-1]));
hmm[x] = *ms.begin();
}
int ans = INT_MIN;
for (int x = 0; x < n; x++){
ans = max(ans, hmm[x]);
}
cout << ans;
}
Compilation message (stderr)
hac.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main(){
| ^~~~
# | 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... |