Submission #882066

#TimeUsernameProblemLanguageResultExecution timeMemory
88206612345678Hacker (BOI15_hac)C++17
100 / 100
72 ms18664 KiB
#include <bits/stdc++.h> using namespace std; const int nx=5e5+5; int n, qs[2*nx], v[nx], res; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; int sz=(n+1)/2; for (int i=1; i<=n; i++) cin>>v[i]; for (int i=1; i<=2*n; i++) qs[i]=qs[i-1]+v[i>n?i-n:i]; for (int i=sz; i<2*sz; i++) pq.push({qs[i]-qs[i-sz], i-sz}); for (int i=sz; i<n+sz; i++) { while (pq.top().second<i-sz) pq.pop(); res=max(res, pq.top().first); pq.push({qs[i+sz]-qs[i], 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...