Submission #723588

#TimeUsernameProblemLanguageResultExecution timeMemory
723588MDSProHacker (BOI15_hac)C++17
100 / 100
226 ms8808 KiB
#include "bits/stdc++.h" using namespace std; const int MAXN = 3e6; const int INF = 1e9; int n,N; vector<int> tr; void build(int n){ N = (1<<(32-__builtin_clz(n))); tr.assign(2*N,INF); } void upd(int l, int r, int val){ if(l >= n) upd(l-n,r-n,val); else if(r > n) { upd(l,n,val); upd(0,r-n,val); } else { for(l += N, r += N; l < r; l >>= 1, r >>= 1){ if(l&1) { tr[l] = min(tr[l],val); l++; } if(r&1) { --r; tr[r] = min(tr[r],val); } } } } int get(int idx){ int ans = INF; for(idx += N; idx > 0; idx >>= 1) ans = min(tr[idx],ans); return ans; } int main(){ cin >> n; vector<int> v(2*n); for(int i = 0,x; i < n; ++i){ cin >> x; v[i] = v[i+n] = x; } build(n); int sum = 0; int need = (n+1)/2; for(int i = 0; i < 2*n; ++i){ sum += v[i]; if(i-need+1 >= 0) { upd(i-need+1,i+1,sum); sum -= v[i-need+1]; } } int res = 0; for(int i = 0; i < n; ++i) res = max(res,get(i)); cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...