# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431832 | muhammad_hokimiyon | Boxes with souvenirs (IOI15_boxes) | C++14 | 2072 ms | 24068 KiB |
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 = abs(p[i] - p[j]);
return min(res, L - res);
};
for(int i = 1; i <= N; i++){
for(int j = i; j >= 1; j--){
if(i - j + 1 > K)break;
long long cost = L;
cost = min(cost, p[i] * 2);
cost = min(cost, (L - p[j]) * 2);
d[i] = min(d[i], d[j - 1] + cost);
}
}
return d[N];
}
Compilation message (stderr)
# | 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... |