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;
using ll = long long;
ll dp[10000000];
long long delivery(int n, int k, int l, int p[]) {
for(int i = 0; i < min(n, k); ++i) {
dp[i] = min({2*p[i], 2*(l-p[0]), l});
}
for(int i = k; i < n; ++i) {
dp[i] = dp[i-k] + min({2*p[i], 2*(l-p[i-k+1]), l});
}
ll res = dp[n-1];
for(int i = max(0, n-k-1); i < n-1; ++i) {
res = min(res, dp[i] + min({2*p[n-1], 2*(l-p[i+1]), l}));
}
if(0) {
for(int i = 0; i < n; ++i) {
cout << dp[i] << ' ';
}
cout << '\n';
}
return res;
}
# | 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... |