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[]) {
vector<long long> left(N), right(N), pre(N);
for (int i = 0; i < N; i++) {
if (i < K) left[i] = p[i];
else left[i] = left[i - K] + p[i];
}
for (int i = N - 1; i >= 0; i--) {
if (i >= N - K) right[i] = L - p[i];
else right[i] = right[i + K] + L - p[i];
}
long long ans = min(2 * left[N - 1], 2 * right[0]);
for (int i = 1; i < N; i++) ans = min(ans, 2 * left[i - 1] + 2 * right[i]);
if (K < N) {
ans = min(ans, L + 2 * right[K]);
ans = min(ans, L + 2 * left[N - K - 1]);
for (int i = 1; i + K < N; i++) ans = min(ans, 2 * left[i - 1] + L + 2 * right[i + K]);
} else {
ans = min(ans, (long long) 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... |