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;
long long dpL[10000005], dpR[10000005];
long long delivery(int N, int K, int L, int p[]) {
for(int i = 1; i <= N; i++) {
dpL[i] = p[i - 1] * 2LL;
if(i > K) dpL[i] += dpL[i - K];
}
for(int i = N; i > 0; i--) {
dpR[i] = (L - p[i - 1]) * 2LL;
if(i + K <= N) dpR[i] += dpR[i + K];
}
long long ans = 1e18;
for(int i = 0; i <= N; i++) {
ans = min(ans, dpL[i] + dpR[i + 1]);
}
for(long long l = 1, r = K; r <= N; l++, r++) {
ans = min(ans, dpL[l - 1] + dpR[r + 1] + L);
}
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... |