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 "boxes.h"
#include <bits/stdc++.h>
using namespace std;
long long n,a[10000069],dp[2][10000069],inf=1e18;
long long delivery(int on,int d,int ln,int aa[])
{
long long i,ii,u,z=inf;
n=on;
for(i=1;i<=n;i++)
{
a[i]=aa[i-1];
}
for(ii=0;ii<2;ii++)
{
u=!ii*2-1;
for(i=1+(n-1)*ii;i!=(n+1)*!ii;i+=u)
{
dp[ii][i]=dp[ii][min(max(i-d*u,0ll),n+1)]+abs(a[i]-ln*ii)*2;
}
}
for(i=0;i<=n;i++)
{
z=min(z,dp[0][i]+min(dp[1][i+1],dp[1][min(i+d+1,n+1)]+ln));
}
return z;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |