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;
typedef long long ll;
const int MAXN = 1e7+5;
ll f[MAXN], b[MAXN];
ll delivery(int N, int K, int L, int p[]) {
fill(f, f+MAXN, -1);
fill(b, b+MAXN, -1);
int i = 0;
while (i < N && f[i] == -1) {
f[i] = p[i] + min(p[i], L - p[i]);
for (int j = i + K; j < N; j += K) {
f[j] = f[j-K] + p[j] + min(p[j], L - p[j]);
}
i++;
}
i = N-1;
while (i >= 0 && b[i] == -1) {
b[i] = L - p[i] + min(p[i], L - p[i]);
for (int j = i - K; j >= 0; j -= K) {
b[j] = b[j+K] + L - p[j] + min(p[j], L - p[j]);
}
i--;
}
ll ans = min(f[N-1], b[0]);
i=0;
for (; i < N - 1; i++) {
ans = min(ans, f[i] + b[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... |