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;
int main() {
int n, a[500003], ans;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int cntTakenByPlayer = n/2 + n%2;
ans = 0;
for (int i = 0; i < n; i++) {
// i-th is player's first move
int minSum = 1000000000;
for (int prev = 0; prev < cntTakenByPlayer; prev++) {
int currSum = 0;
for (int j = (i - 1 + n)%n, cnt = 0; cnt < prev; j = (j - 1 + n)%n, cnt++) {
currSum += a[j];
}
for (int j = i, cnt = 0; cnt < cntTakenByPlayer - prev; j = (j + 1)%n, cnt++) {
currSum += a[j];
}
minSum = min(minSum, currSum);
}
ans = max(ans, minSum);
}
cout << ans << endl;
}
# | 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... |