# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26831 | yutaka1999 | Hacker (BOI15_hac) | C++14 | 166 ms | 33268 KiB |
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 <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#define SIZE 500005
using namespace std;
typedef long long int ll;
ll sum[SIZE*2];
ll ans[SIZE*2];
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
ll a;
scanf("%lld",&a);
sum[i]=a;
if(i>0) sum[i]+=sum[i-1];
}
for(int i=n;i<2*n;i++) sum[i]=sum[n-1]+sum[i-n];
for(int i=0;i<n;i++) ans[i]=sum[n-1];
int L=(n+1)/2;
priority_queue <ll,vector <ll>,greater <ll> > que,rem;
for(int i=2*n-1;i>=L;i--)
{
if(i>=L-1) que.push(sum[i]-(i==L-1?0:sum[i-L]));
if(i+L<=2*n-1) rem.push(sum[i+L]-sum[i]);
while(!rem.empty()&&rem.top()==que.top()) que.pop(),rem.pop();
ans[i%n]=min(ans[i%n],que.top());
}
ll ret=0;
for(int i=0;i<n;i++) ret=max(ret,ans[i]);
printf("%lld\n",ret);
return 0;
}
Compilation message (stderr)
# | 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... |