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;
#define N 10000005
long long dp1[N],dp2[N],ans=1e18;
long long delivery(int n,int k,int l,int pos[N]){
int i;
for(i=1;i<=n;i++)dp1[i]=dp1[max(0,i-k)]+pos[i-1]+min(pos[i-1],l-pos[i-1]);
for(i=n;i>0;i--)dp2[i]=dp2[min(n+1,i+k)]+l-pos[i-1]+min(pos[i-1],l-pos[i-1]);
for(i=0;i<=n;i++)ans=min(ans,dp1[i]+dp2[i+1]);
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... |