Submission #516241

#TimeUsernameProblemLanguageResultExecution timeMemory
516241sidonHacker (BOI15_hac)C++17
100 / 100
53 ms8588 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0); int N; cin >> N; int a[N] = {}, b[2*N], pref = 0; int x = (N + 1) / 2; for(int &i : a) cin >> i; for(int i = 0; i - x < N; i++) { if(i && i < N) a[i] += a[i-1]; pref = a[i % N]; if(i >= N) pref += a[N - 1]; if(i >= x) b[i-x+N] = b[i-x] = pref - a[i-x]; } int *l = a, *r = a, res = 0; for(int i = 0; i < 2*N; i++) { while(l != r && b[*(r-1)] >= b[i]) --r; (*r++) = i; while(*l <= i-x) ++l; if(i >= x-1) res = max(res, b[*l]); } 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...