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;
#define ll long long
#define N ((int)1e7+10)
ll dp[N];
ll delivery(int n,int k, int l, int p[])
{
int id=0;
for(int i=0;i<n && p[i]<=l/2;i++,id++)
dp[i]=2*p[i]+((i-k<0)?0:dp[i-k]);
for(int i=n-1;i>=id;i--)
dp[i]=2*(l-p[i])+((i+k>=n)?0:dp[i+k]);
ll ans=min((ll)(n+k-1)/k*l,((id>0)?dp[id-1]:0)+dp[id]);
int lft=max(0,id-k),rght=lft+k;
while(lft<=id && rght<=n)
ans=min(ans,dp[rght]+((lft>0)?dp[lft-1]:0)+l),
lft++,rght++;
return ans;
}
# | 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... |