Submission #31592

#TimeUsernameProblemLanguageResultExecution timeMemory
31592minhtung0404Hacker (BOI15_hac)C++14
0 / 100
0 ms13732 KiB
#include<bits/stdc++.h> const int N = 5e5 + 5; using namespace std; deque <long long> mq; long long n, a[N], sum[2*N], maxx, siz; int main(){ cin >> n; siz = (n+1)/2; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= siz; i++) sum[1] += a[i]; for (int i = 2; i <= n; i++){ int z = i-1+siz; if (z > n) z -= n; sum[i] = sum[i-1] + a[z] - a[i-1]; } for (int i = 1; i <= n; i++) sum[n+i] = sum[i]; for (int i = 1; i <= 2*n; i++){ while(mq.size() && sum[mq.front()] >= sum[i]) mq.pop_front(); mq.push_front(i); if (i - mq.back() == siz) mq.pop_back(); maxx = max(sum[mq.back()], maxx); } cout << maxx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...