This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |