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;
typedef vector<int> vi;
typedef vector<vi> vvi;
vi pre, computers;
int N;
int calcInterval(int left, int right){
if(left > right) return pre[N-1] - (pre[left]-pre[right]);
return pre[right] - pre[left];
}
int main(){
cin >> N;
computers = vi(N);
pre = vi(N);
cin >> computers[0];
pre[0] = computers[0];
for(int i = 1; i < N; ++i){
cin>> computers[i];
pre[i] = pre[i-1] + computers[i];
}
int length = N/2 + N%2;
int ans = 0;
for(int start = 0; start < N; ++start){
int val = calcInterval((start-1 + N)%N, (start + length-1)%N);
for(int left = 0; left < N; ++left){
int right = (left + length)%N ;
if ((left < start and right>= start) or (right >= start and left > right)) val = min(val, calcInterval(left, right));
}
//cout << start << " " << val << endl;
ans = max(ans, val);
}
cout << ans << endl;
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... |