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 ans, dp1[10000001], dp2[10000001];
long long delivery(int n, int k, int l, int a[]){
for(long long i=0; i<n; i++){
dp1[i+1]=2*a[i];
if(i>=k) dp1[i+1]+=dp1[i-k+1];
}
for(long long i=n-1; i>=0; i--){
dp2[i+1]=2*(l-a[i]);
if(i<n-k) dp2[i+1]+=dp2[i+k+1];
}
ans=min(dp1[n], dp2[1]);
for(long long i=1; i<=n-k+1; i++)
ans=min(ans, dp1[i-1]+l+dp2[i+k]);
for(long long i=1; i<n; i++)
ans=min(ans, dp1[i]+dp2[i+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... |