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>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll dp[2000][2000];
long long delivery(int N, int K, int L, int p[]) {
memset(dp,0x3f,sizeof(dp));
dp[0][0]=0;
rep(i,N)rep(j,K){
if(dp[i][j]==INF)continue;
if(j==0){
dp[i+1][0]=min(dp[i+1][0],dp[i][j]+min(p[i],L-p[i])*2);
if(1<K)dp[i+1][1]=min(dp[i+1][1],dp[i][j]+min(p[i],L-p[i]));
}
else{
dp[i+1][0]=min(dp[i+1][0],dp[i][j]+min(p[i],L-p[i])+(p[i]-p[i-1]));
if(j+1<K)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+(p[i]-p[i-1]));
}
}
return dp[N][0];
}
# | 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... |