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 delivery(int N, int K, int L, int p[]) {
long long ans, D[N] = {}, D2[N] = {};
int l = 0;
for (int i = 0; i < N; ++i) {
if (i % K == 0) {
l = 0;
}
D[i] = 2 * (p[i] - l);
if (i) {
D[i] += D[i - 1];
}
l = p[i];
}
l = L;
for (int i = N - 1; ~i; --i) {
if ((N - i) % K == 0) {
l = L;
}
D2[i] = 2 * (l - p[i]);
if (i < N - 1) {
D2[i] += D2[i + 1];
}
l = p[i];
}
ans = min(D[N - 1], D2[0]);
for (int i = 0; i < N - 1; ++i) {
ans = min(ans, D[i] + D2[i + 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... |