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;
typedef long long LL;
const LL INF=1e18;
LL dp[1005];
LL dist(LL x,LL y,LL mod){
return min((y-x+mod)%mod,(x-y+mod)%mod);
}
LL cost(LL a,LL b,LL mod){
return dist(a,0,mod)+(b-a+mod)%mod+dist(b,0,mod);
}
LL delivery(int N, int K, int L, int p[]) {
dp[0]=0;
for(LL i=1;i<=N;i++){
dp[i]=INF;
for(LL j=max(i-K,0LL);j<=i-1;j++){
dp[i]=min(dp[i],dp[j]+cost(p[j],p[i-1],L));
}
}
return dp[N];
}
# | 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... |