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;
const int N = 5e5 + 5;
int s[2 * N], a[2 * N], n, m[2 * N];
multiset<int> st;
int main() {
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i], a[i + n] = a[i];
for(int i = 1; i <= 2 * n; ++i) s[i] = s[i - 1] + a[i];
int len = (n + 1) / 2, ans = 0;
for(int i = 1; i <= 2 * n - len + 1; ++i) m[i] = s[i + len - 1] - s[i - 1];
for(int i = 1; i <= 2 * n - len + 1; ++i) {
if(i > len) {
multiset<int>::iterator it = st.find(m[i - len]);
st.erase(it);
}
st.insert(m[i]);
if(i >= len) ans = max(ans, *st.begin());
}
cout << ans;
}
# | 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... |