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 M = 1000000000000000000;
long long delivery(int n, int k, int l, int p[]) {
vector<ll> dp1(n + 1, M);
dp1[0] = 0;
multiset<ll> sett1;
sett1.insert(0);
for (int i = 0; i < n; i++)
{
dp1[i + 1] = *sett1.begin() + 2 * p[i];
sett1.insert(dp1[i + 1]);
if (i + 1 - k >= 0) sett1.erase(sett1.find(dp1[i + 1 - k]));
}
vector<ll> dp2(n + 1, M);
dp2[0] = 0;
multiset<ll> sett2;
sett2.insert(0);
for (int i = 0, j = n - 1; i < n; i++, j--)
{
dp2[i + 1] = *sett2.begin() + 2 * (l - p[j]);
sett2.insert(dp2[i + 1]);
if (i + 1 - k >= 0) sett2.erase(dp2[i + 1 - k]);
}
ll res = M;
for (int cycle = 0; cycle < n; cycle++)
{
ll cur = l;
cur *= cycle;
for (int i = 0; i + cycle * k <=n; i++)
{
ll cur2 = cur;
cur2 += dp1[i];
cur2 += dp2[n - i - cycle];
res = min(res, cur2);
}
}
return res;
}
# | 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... |