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 INF 1e18
using namespace std;
using ll = long long;
long long delivery(int N, int K, int L, int p[]) {
ll l[N+1], r[N+1];
l[0] = r[0] = 0;
for(ll i=1;i<=N;i++)
{
l[i] = l[max(i-K,0ll)]+p[i-1]*2;
r[i] = r[max(i-K,0ll)]+(L-p[N-i])*2;
}
ll res = INF;
for(ll tl=0;tl<=N;tl++)
{
ll tr = N-tl;
res = min(res,l[tl]+r[tr]);
ll tr2 = max(N-tl-K,0ll);
res = min(res,l[tl]+r[tr2]+L);
}
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... |