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 fi first
#define se second
#define ll long long
#define dl double
using namespace std;
ll delivery(int N, int K, int L, int P[])
{
vector<ll> d(N + 1, 1e18);
d[0] = 0;
vector<ll> p(N + 1, 0);
for(int i = 1; i <= N; i++)p[i] = P[i - 1];
sort(p.begin(), p.end());
auto go = [&](int i, int j) -> ll{
ll res = 1e18;
res = min(res, abs(p[i] - p[j]));
res = min(res, L - p[i] + p[j]);
res = min(res, L - p[j] + p[i]);
return res;
};
for(int i = 1; i <= N; i++){
for(int j = i; j >= 1; j--){
if(i - j + 1 > K)break;
d[i] = min(d[i], d[j - 1] + go(0, i) + go(i, j) + go(j, 0));
}
}
return d[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... |