#include<bits/stdc++.h>
#include "boxes.h"
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
using namespace std;
long long delivery(int N, int K, int L, int p[])
{
ll pos[N+1];
for(ll i = 1; i <= N; i++)
pos[i] = p[i-1];
ll x[N+1], y[N+1];
x[0] = 0;
for(ll i = 1; i <= N; i++)
{
if(i <= K)
x[i] = pos[i] * 2;
else
x[i] = x[i-K] + pos[i] * 2;
}
y[N+1] = 0;
for(ll i = N; i >= 1; i--)
{
if(N - i + 1 <= K)
y[i] = (L - pos[i]) * 2;
else
y[i] = y[K+i] + (L - pos[i]) * 2;
}
ll res = min(x[N], y[1]);
for(ll i = 1; i <= N - 1; i++)
res = min(res, x[i] + y[i+1]);
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... |