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;
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
#define int ll
int mod = 998244353;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> arr(2*n+1, 0);
multiset<int> vals;
int sz = (n+1)/2;
for(int i = 1; i <= n; ++i){
cin >> arr[i];
arr[i+n] = arr[i];
}
for(int i = 1; i <= 2*n; ++i){
arr[i] += arr[i-1];
}
int ans = 0;
vector<int> ret(n+1 ,INT_MAX);
for(int i = 1; i <= 2*n;++i){
if(i+sz-1<=2*n){
vals.insert(arr[i+sz-1]-arr[i-1]);
}
if(i>sz){
vals.erase(vals.find(arr[i-1]-arr[i-1-sz]));
}
int prev = ((i-1)%n)+1;
ret[prev] = min(ret[prev], *vals.begin());
}
for(int i = 1; i <= n;++i){
ans = max(ans, ret[i]);
}
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... |