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;
#define int int64_t
long long delivery(signed N, signed K, signed L, signed p[]) {
vector<int> costUntilCW(N);
vector<int> costUntilCCW(N);
for (int i = 0; i<N; i++) {
costUntilCW[i] = (i-K>=0?costUntilCW[i-K]:0)+p[i];
// cerr << costUntilCW[i] << " ";
}
// cerr << "\n";
for (int i = N-1; i>=0; i--) {
costUntilCCW[i] = (i+K<N?costUntilCCW[i+K]:0)+L-p[i];
// cerr << costUntilCCW[i] << " ";
}
// cerr << "\n";
int res = min(costUntilCW[N-1]*2, costUntilCCW[0]*2);
for (int i = 0; i<N-1; i++) {
res = min(res, costUntilCW[i]*2 + costUntilCCW[i+1]*2);
if (i+K+1 < N) res = min(res, costUntilCW[i]*2 + costUntilCCW[i+K+1]*2 + L);
}
return res;
}
# | 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... |