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;
long long delivery(int N, int K, int L, int p[]) {
long long dp[N],dp2[N];
for (int i=0;i<N;i++){
if (i-K>=0) dp[i]=dp[i-K]+(p[i])*2;
else dp[i]=p[i]*2;
}
for (int i=N-1;i>=0;i--){
if (i+K<N) dp2[i]=dp2[i+K]+(L-p[i])*2;
else dp2[i]=(L-p[i])*2;
}
long long minans=1e18;
for (int i=0;i<N-1;i++){
minans=min(minans,dp[i]+dp2[i+1]);
}
for (int i=K;i<N;i++){
minans=min(minans,dp[i-K]+dp2[i+1]+L);
}
minans=min(minans,dp[N-1]);
minans=min(minans,dp2[0]);
minans=min(minans,dp2[K]+L);
minans=min(minans,dp[N-K]+L);
return minans;
}
# | 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... |