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 <bits/stdc++.h>
#include "boxes.h"
using namespace std;
typedef long long ll;
ll delivery(int N, int K, int L, int p[]) {
vector<ll> tmp(K), dpl(N), dpr(N);
for (int i = 0; i < N; i++) {
tmp[i % K] += p[i] + min(p[i], L - p[i]);
dpl[i] = tmp[i % K];
}
tmp.assign(K, 0);
for (int i = N; i--; ) {
tmp[i % K] += L - p[i] + min(p[i], L - p[i]);
dpr[i] = tmp[i % K];
}
ll ans = min(dpl[N - 1], dpr[0]);
for (int i = 1; i < N; i++)
ans = min(ans, dpl[i - 1] + dpr[i]);
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... |