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>
#include "boxes.h"
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 10000100;
ll dp[maxn], n, k, l;
int arr[maxn];
long long delivery(int N, int K, int L, int p[]) {
for(int i=0;i<N;i++) {
arr[i+1] = p[i];
}
n = N; k = K; l = L;
for(int i=1;i<=n;i++) {
// solve for prefix of size i
dp[i] = LLONG_MAX;
for(ll j=i-1;j>=max(0LL, i-k);j--) {
ll cost = dp[j] + min(l, min(2LL*arr[i], 2LL*(l-arr[j+1])));
dp[i] = min(dp[i], cost);
}
}
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... |