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 <bits/stdc++.h>
#include "boxes.h"
using namespace std;
using ll = long long;
ll inf = (ll)1e9 * (ll)1e9;
ll delivery(int N, int k, int L, int positions[])
{
vector<int> p(N + 1);
for (int i = 1; i <= N; i++)
p[i] = positions[i - 1];
ll ans = inf;
vector<int> revp(N + 1);
vector<ll> pref(N + 1), suf(N + 1);
for (int i = 1; i <= N; i++)
revp[i] = (L - p[i]);
for (int i = 1; i <= N; i++)
{
pref[i] = min(L, 2 * p[i]) + pref[max(0, i - k)];
}
for (int i = N; i >= 1; i--)
{
suf[i] = min(L, 2 * revp[i]);
if (i + k <= N)
suf[i] += suf[i + k];
}
for (int m = 0; m <= N; m++)
{
ll kk = pref[m];
if (m + 1 <= N)
kk += suf[m + 1];
ans = min(ans,kk);
}
return ans;
}
# | 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... |