이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
res = min(res, costUntilCW[max(0, N-1-K)]*2 + L);
res = min(res, costUntilCCW[min(N-1, K)]*2 + L);
if (K >= N) res = min(res, (int)L);
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... |