#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long delivery(int N, int K, int l, int p[]) {
    ll L = l;
    vector<ll> firsthalf, secondhalf;
    firsthalf.push_back(0);
    for(int i = 0; i < N; i++){
        if(p[i] <= L / 2){
            firsthalf.push_back(p[i]);
        } else {
            secondhalf.push_back(p[i]);
        }
    }
    secondhalf.push_back(L);
    return min(firsthalf.back() * 2 + (L - secondhalf[0]) * 2, L);
}
| # | 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... |