# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034010 | fv3 | Boxes with souvenirs (IOI15_boxes) | C++14 | 2040 ms | 37460 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>
using namespace std;
typedef long long ll;
const ll INF = 1ll << 60;
ll delivery(int N_, int K_, int L_, int p[])
{
ll L = L_; ll N = N_; ll K = K_;
vector<ll> v(N);
for (int i = 0; i < N; i++)
v[i] = p[i];
sort(v.begin(), v.end());
// Subtask 5: K <= 3000
// Solve with Dynamic Programming
// Let DP_r[i] be the minimum time to deliver the first i
// packages and go back to start while only going right
// Let DP_l[i] be the minimum time to deliver the last i
// packages and go back to start while only going left
// Find the optimal place to stop going right
vector<ll> DP_r(N + 1, INF), DP_l(N + 1, INF);
DP_r[0] = 0; DP_l[N] = 0;
for (int i = 0; i < N; i++)
{
for (int j = i + 1; j <= min(N, K + i); j++)
{
DP_r[j] = min({DP_r[j], DP_r[i] + v[j - 1] * 2, DP_r[i] + L});
}
}
for (int i = N; i >= 1; i--)
{
for (int j = i - 1; j >= max(0ll, i - K); j--)
{
DP_l[j] = min({DP_l[j], DP_l[i] + (L - v[j]) * 2, DP_l[i] + L});
}
}
ll res = INF;
for (int i = 0; i <= N; i++)
res = min(res, DP_r[i] + DP_l[i]);
return res;
}
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... |