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, A[N], A2[N], KS = 0;
for (int i = 0; i < N; ++i) {
if (i % K == 0 && i) {
KS += 2 * p[i - 1];
}
A[i] = KS + 2 * p[i];
}
KS = 0;
for (int i = N - 1; ~i; --i) {
if ((N - i - 1) % K == 0 && i < N - 1) {
KS += 2 * (L - p[i]);
}
A2[i] = KS + 2 * (L - p[i]);
}
ans = K == N ? L : A[N - K - 1] + L;
for (int i = 0; i + K - 1 < N; ++i) {
ans = min(ans, A[i] + A2[i + K - 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... |