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;
const int MAX = 1e7 + 10;
const long long INF = 1e18 + 7;
long long pre[MAX], suf[MAX];
long long delivery(int N, int K, int L, int p[]) {
for(int i = 1; i <= N; i++) {
pre[i] = pre[max(0, i - K)] + p[i - 1] + min(p[i - 1], L - p[i - 1]);
}
for(int i = N; i >= 1; i--) {
suf[i] = suf[min(N + 1, i + K)] + (L - p[i - 1]) + min(p[i - 1], L - p[i - 1]);
}
long long ans = INF;
for(int i = 0; i <= N; i++) {
ans = min(ans, pre[i] + suf[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... |