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 <iostream>
#include <algorithm>
#include <vector>
#include "boxes.h"
using namespace std;
using ll = long long;
vector <ll> l(1e7, 0);
vector <ll> r(1e7, 0);
ll delivery(int N, int K, int L, int p[]) {
for (int i = 0; i < N; i++) l[i] = i < K ? 2 * p[i] : l[i - K] + 2 * p[i];
for (int i = N - 1; i >= 0; i--) r[i] = i >= N - K ? 2 * (L - p[i]) : r[i + K] + 2 * (L - p[i]);
ll ans = 1e17;
ans = min(ans, r[K] + L);
ans = min(ans, l[N - K - 1] + L);
for (int i = 0; i < N - K - 1; i++) ans = min(ans, l[i] + r[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... |