#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
ll delivery(int n, int k, int L, int X[]){
    vector<int> x(n + 1);
    for (int i = 1; i <= n; i++) x[i] = X[i - 1];
    sort(x.begin() + 1, x.end());
    vector<ll> dp(n + 1, 1e18); dp[0] = 0;
    for (int i = 1; i <= n; i++){
        for (int j = max(1, i - k + 1); j <= i; j++){
            dp[i] = min({dp[i], dp[j - 1] + L, dp[j - 1] + 2 * x[i], dp[j - 1] + 2 * (L - x[j])});
        }
    }
    return dp[n];
}
| # | 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... |