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;
inline void fastio();
ll n, arr[200001], sum[200001], ans, mx;
int main() {
fastio();
cin >> n;
for (ll i = 0; i < n; i++) {
cin >> arr[i];
arr[i + n] = arr[i];
mx = max(mx, arr[i]);
}
for (ll i = 0; i < 2 * n; i++) {
sum[i + 1] = sum[i] + arr[i];
}
for (ll i = 0; i < n; i++) {
ll s = 0, e = sum[2 * n];
while (s - e + 1 < 0) {
ll m = (s + e) / 2;
bool chk = true;
for (ll j = 0, loc = i; j < 3; j++) {
loc = lower_bound(sum, sum + 2 * n + 1, m + sum[loc]) - sum;
if (loc > i + n) {
chk = false;
break;
}
}
if (chk) {
s = m;
} else {
e = m;
}
}
ans = max(ans, s);
}
cout << ans << '\n';
}
inline void fastio() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
# | 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... |