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 d1[10000005], d2[10000005];
long long delivery(int N, int K, int L, int p[]) {
long long ans = 1e18;
for(int i = 0; i < N; i ++){
if(i < K){
d1[i] = p[i] + min(L - p[i], p[i]);
} else {
d1[i] = (p[i] + min(L - p[i], p[i])) + d1[i - K];
}
}
for(int i = N - 1, cn = 0; i >= 0; i --, cn ++){
if(cn < K){
d2[i] = (L - p[i]) + min(L - p[i], p[i]);
} else {
d2[i] = ((L - p[i]) + min(L - p[i], p[i])) + d2[i + K];
}
}
for(int i = 0; i < N; i ++){
ans = min(ans, d1[i] + d2[i + 1]);
}
long long res = 0;
for(int j = 0; j < N; j += K){
res += (L - p[j]) + min(p[j], L - p[j]);
}
ans = min(ans, res);
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... |