# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1270581 | nathan4690 | Hacker (BOI15_hac) | C++20 | 227 ms | 35672 KiB |
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f1(i,n) for(int i=1;i<=n;i++)
#define __file_name ""
using namespace std;
const ll maxn = 2e6+5, inf=1e18;
ll n, a[maxn], pf[maxn], cnt, ans;
multiset<ll> S;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
if(fopen(__file_name ".inp", "r")){
freopen(__file_name ".inp","r",stdin);
freopen(__file_name ".out","w",stdout);
}
// code here
cin >> n;
f1(i,n) cin >> a[i];
cnt = (n + 1) / 2;
for(int i=n+1;i<=3*n;i++) a[i] = a[i - n];
f1(i, 3*n) pf[i] = pf[i-1] + a[i];
for(int i=n+1;i<=n+cnt;i++){
S.insert(pf[i] - pf[i - cnt]);
}
ans = *S.begin();
for(int i=n+2;i<=2*n;i++){
S.erase(S.find(pf[i-1] - pf[i - cnt - 1]));
S.insert(pf[i + cnt - 1] - pf[i - 1]);
ans = max(ans, *S.begin());
// cout << S.size() << '\n';
}
cout << ans;
return 0;
}
Compilation message (stderr)
# | 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... |