#include <bits/stdc++.h>
#define int int64_t
signed main() {
int n;
std::cin >> n;
std::vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
std::cin >> a[i];
}
int ans = 0;
for(int i = 1; i <= n; i++) {
std::vector<int> b;
std::vector<int> c(n + 1);
for(int j = i; j <= n; j++) {
b.push_back(a[j]);
}
for(int j = i - 1; j >= 1; j--) {
b.push_back(a[j]);
}
for(int j = 1; j <= n; j++) {
c[j] = b[j - 1];
}
std::vector<int> pref(n + 1), suff(n + 2);
for(int j = 1; j <= n; j++) {
pref[j] = pref[j - 1] + c[j];
}
for(int j = n; j >= 1; j--) {
suff[j] = suff[j + 1] + c[j];
}
int mn = 1e18;
int k = (n + 1) / 2;
for(int j = 1; j <= k; j++) {
mn = std::min(mn, pref[j] + suff[j - k + n + 1]);
}
ans = std::max(ans, mn);
break;
}
std::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... |