이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define N 500005
#define int long long
int n, a[2 * N], res[N];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
res[i] = 1e18;
a[i + n] = a[i];
a[i] += a[i - 1];
}
for (int i = n + 1; i <= 2 * n; i++){
a[i] += a[i - 1];
}
int sz = (n + 1) / 2;
multiset<int> st;
for (int i = 1; i <= 2 * n; i++){
if (i + sz - 1 <= 2 * n){
st.insert(a[i + sz - 1] - a[i - 1]);
}
if (i > sz){
st.erase(st.find(a[i - 1] - a[i - 1 - sz]));
}
int pos = ((i - 1) % n) + 1;
res[pos] = min(res[pos], *st.begin());
}
int ans = 0;
for (auto i = 1; i <= n; i++) ans = max(ans, res[i]);
cout << ans;
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... |