#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int mxN = 1e6+5;
ll delivery(int n, int k, int l, int* a) {
vector<int> pos(n);
for (int i=0; i<n; i++) {
pos[i] = a[i];
}
ll dp[mxN];
for (int i=0; i<n; i++) {
dp[i] = 1e18;
}
dp[0] = 2*min(pos[0], l-pos[0]);
for (int s=0; s<k; s++) {
int le = pos[0];
int r = pos[0+s];
ll coste = min(2*min(r, l-le), l);
dp[s] = coste;
}
for (int i=0; i<n; i++) {
for (int s=1; s<=k; s++) {
if (i+s >= n) break;
int le = pos[i];
int r = pos[i+s];
ll coste = min(2*min(r, l-le), l);
//cout << i << " " << s << " " << dp[i] << " " << coste << endl;
dp[i+s] = min(dp[i+s], dp[i]+coste);
}
//cout << dp[i] << endl;
}
return dp[n-1];
}
| # | 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... |