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;
inline vector<LL> linear_cost(int n, int k, int p[]) {
vector<LL> ans(n+1); ans[0] = 0;
for (int i = 1; i <= n; ++i) {
ans[i] = 2 * p[i-1] + ans[max(0, i - k)];
}
return ans;
}
LL delivery(int n, int k, int l, int p[]) {
assert(p[0] != 0);
auto ca = linear_cost(n, k, p);
for (int i = 0; i < n; ++i) p[i] = l - p[i];
reverse(p, p + n);
auto cb = linear_cost(n, k, p);
LL ans = 1e18;
for (int i = 0; i <= n; ++i) {
ans = min(ans, ca[i] + cb[n - i]);
}
for (int a = 0; a < n; ++a) {
for (int b = a; b < n && b - a < k; ++b) {
ans = min(ans, l + ca[a] + cb[n - b - 1]);
}
}
return ans;
}
# | 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... |