이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* author: wxhtzdy
* created: 20.07.2022 16:47:00
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<long long> pref(2 * n + 1);
for (int i = 0; i < 2 * n; i++) {
pref[i + 1] = pref[i] + a[i % n];
}
int moves = (n + 1) / 2;
vector<long long> val(n + 1);
for (int i = 1; i <= n; i++) {
val[i] = pref[i + moves - 1] - pref[i - 1];
}
long long ans = 0;
for (int i = 1; i <= n; i++) {
long long mn = val[i];
for (int j = 0; j < moves; j++) {
int idx = i - j;
if (idx <= 0) {
idx = idx + n;
}
mn = min(mn, val[idx]);
}
ans = max(ans, mn);
}
cout << ans << '\n';
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... |