#include<bits/stdc++.h>
#include "boxes.h"
#include<ext/pb_ds/assoc_container.hpp>
/**zagaro & lauren <3**/
#define mod 1000000007 //1e9 + 7
#define pi acos(-1)
#define wl while
#define str string
#define ENDL "\n"
#define sal ' '
#define tp_set ll
#define prc(n) cout.precision(n);cout<<fixed;
#define ord_set tree<tp_set, null_type, less<tp_set>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef bool bl;
typedef char car;
using namespace std;
using namespace __gnu_pbds;
ll delivery(int N, int K, int L, int p[]) {
    ll r=LONG_LONG_MAX, x, a, b;
    vector<ll> vec(N, LONG_LONG_MAX);
    for(int i=0;i<min(N, K);i++){
        vec[i] = min(p[i], L-p[i])*2;
    }
    x=1;
    for(int i=K;i<N;i++){
        if(p[i] <= L/2)a=2*p[i];
        else if(p[x] >= L/2)a=2*(L-p[i]);
        else a=L;
        if(i >= N-K){
            r = min(r, vec[i-1] + min(p[i], L-p[i])*2);
        }
        vec[i] = vec[i-K] + a;
        x++;
    }
    r = min(r, vec[N-1]);
    return r;
}
| # | 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... |