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 dp[1000100];
long long delivery(int N, int K, int L, int p[]) {
int mid = L/2;
for (int i = 1; i <= N; i++){
dp[i] = 1e18;
bool bb = 0;
int pos = p[i-1];
for (int j = 1; j <= K; j++){
if (i-j < 0)
break;
int pos2 = p[i-j];
if (mid != pos2 && mid != pos && (mid-pos2)/abs(mid-pos2) != (mid-pos)/abs(mid-pos) ){
bb = 1;
}
if (bb){
dp[i] = min(dp[i], dp[i-j] + L);
} else {
dp[i] = min(dp[i], dp[i-j] + max(min(pos2, L-pos2), min(pos, L-pos))*2);
}
}
}
return dp[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... |