Submission #97088

#TimeUsernameProblemLanguageResultExecution timeMemory
97088dalgerokHacker (BOI15_hac)C++14
0 / 100
3 ms552 KiB
#include<bits/stdc++.h> using namespace std; const int N = 15e5 + 5; int n, m, sum, a[N], b[N]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; a[i + n] = a[i + 2 * n] = a[i]; } m = (n + 1) / 2; sum = 0; for(int i = 1; i <= n; i++){ sum += a[i]; if(i > m){ sum -= a[i - m]; } b[i] = sum; } deque < int > q; int ans = 0; for(int i = 1; i <= 3 * n; i++){ while(!q.empty() && b[q.back()] >= b[i]){ q.pop_back(); } q.push_back(i); while(!q.empty() && q.front() + m <= i){ q.pop_front(); } ans = max(ans, b[q.front()]); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...