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>
#define uwu return ans;
using namespace std;
const int SIZE = 1e3 + 5;
long long calc(int l, int r, int L){
return min({L, 2 * r, 2 * (L - l)});
}
const long long INF = 1e18;
long long dp[SIZE];
long long delivery(int N, int K, int L, int p[]) {
long long ans = INF;
vector <int> pos;
for(int i = 0; i < N; i++){
pos.push_back(p[i]);
}
pos.push_back(0);
sort(pos.begin(), pos.end());
for(int i = 1; i <= N; i++){
dp[i] = INF;
for(int j = max(i - K, 0); j < i; j++){
dp[i] = min(dp[i], dp[j] + calc(pos[j + 1], pos[i], L));
}
}
ans = dp[N];
uwu
}
# | 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... |