This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll inf=1e18;
long long delivery(int n, int k, int l, int p[]) {
vector<ll> dp1(n+2),dp2(n+2);
for(int i=1;i<k;i++){
dp1[i]=2*p[i-1];
}
for(int i=k;i<=n;i++){
dp1[i]=dp1[i-k]+2*p[i-1];
}
for(int i=n;i>n-k;i--){
dp2[i]=2*(l-p[i-1]);
}
for(int i=n-k;i>=1;i--){
dp2[i]=dp2[i+k]+2*(l-p[i-1]);
}
ll ans=inf;
for(int i=0;i<=n;i++){
ans=min(ans,dp1[i]+dp2[i+1]);
ans=min(ans,dp1[i]+l+dp2[min(n+1,i+k+1)]);
}
return ans;
}
# | 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... |