#include "bits/stdc++.h"
#include "boxes.h"
using namespace std;
#define ll long long
#define all(x) x.begin() , x.end()
#define sz(x) (ll)x.size()
const ll INF = 1e18 + 5;
ll delivery(int N, int K, int L, int p[]){
ll n = N, k = K , l = L;
ll ar[n + 5], pre[n + 5], suf[n + 5];
for(ll i = 1 ; i <= n ; i++) ar[i] = p[i - 1];
pre[0] = suf[n + 1] = 0;
for(ll i = 1 ; i <= n ; i++) pre[i] = ar[i] * 2 + pre[max(0LL , i - k)];
for(ll i = n ; i >= 1; i--) suf[i] = 2 * (l - ar[i]) + suf[min(n + 1 , i + k)];
ll ans = INF;
for(ll i = 0; i <= n ; i++) ans = min(ans, pre[i] + suf[i+1]);
if(k == n) ans = min(ans, l);
for(int i = k ; i <= n ; i++) ans = min(ans, l + pre[i - k] + suf[i+1]);
return ans;
}
/*void _(){
ll n,k,l;
cin >> n >> k >> l;
ll ar[n + 5], pre[n + 5], suf[n + 5];
for(ll i = 1 ; i <= n ; i++) cin >> ar[i];
pre[0] = suf[n + 1] = 0;
for(ll i = 1 ; i <= n ; i++) pre[i] = ar[i] * 2 + pre[max(0LL , i - k)];
for(ll i = n ; i >= 1; i--) suf[i] = 2 * (l - ar[i]) + suf[min(n + 1 , i + k)];
ll ans = INF;
for(ll i = 0; i <= n ; i++) ans = min(ans, pre[i] + suf[i+1]);
cout << ans << '\n';
}
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
ll tc = 1;//cin >> tc;
while(tc--) _();
}*/
# | 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... |