이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long delivery(int N, int K, int L, int positions[]){
long long ans = LONG_LONG_MAX;
long long w[N], c[N];
for(int j = 0;j < N;j++){
if(j < K) w[j] = min(positions[j], L - positions[j]) + positions[j];
else w[j] = min(positions[j], L - positions[j]) + w[j-K] + positions[j];
}
for(int j = N-1;j >= 0;j--){
if(j + K >= N) c[j] = min(positions[j], L - positions[j]) + L - positions[j];
else c[j] = min(positions[j], L - positions[j]) + c[j+K] + L - positions[j];
}
for(int i = -1;i < N;i++){
if(i == -1) ans = min(ans, c[0]);
else if (i == N - 1) ans = min(ans, w[N-1]);
else ans = min(ans, w[i] + c[i+1]);
}
return ans;
}
//int main(){
// int p[] = {1, 9, 11, 19};
// cout << delivery(4, 2, 20, p) << '\n';
//}
# | 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... |