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;
const long long inf = 1e18L + 20;
const int maxN = 1e7 + 20;
long long dp[maxN];
long long delivery(int N, int K, int L, int A[]) {
for (int i = 0; i < K; i++) {
dp[i] = min(min(A[i] * 2, (L - A[0]) * 2), L);
}
for (int i = K; i < N - 1; i++) {
dp[i] = dp[i - K] + min(min(A[i] * 2, (L - A[i - K + 1]) * 2), L);
}
dp[N - 1] = inf;
for (int j = 1; j <= K; j++) {
dp[N - 1] = min(dp[N - 1], dp[N - 1 - j] + min(min(A[N - 1] * 2, (L - A[N - 1 - j + 1]) * 2), L));
}
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... |