#include<bits/stdc++.h>
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define mod 1'000'000'007
#define inf 1'000'000'000'000'00
#define pb push_back
#define vvi vector<vi>
#define fst ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
#include "boxes.h"
long long delivery(int n, int k, int L, int a[]){
long long res = LONG_MAX;
vector<long long> dpc(n+1, 0), dpcc(n+1, 0);
for(int i = 1; i <= n; i++){
if(i > k) dpc[i] = dpc[i-k];
dpc[i] += min(L, 2*a[i-1]);
}
for(int i = n-1; i >= 0; i--){
if(i < n-k) dpcc[i] = dpcc[i+k];
dpcc[i] += min(L, 2*(L - a[i]));
}
for(int i = 0; i <= n; i++){
res = min(res, dpc[i] + dpcc[i]);
}
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... |