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 arr[]) {
int prefix[n+5];
int suffix[n+5];
memset(prefix,0,sizeof(prefix));
memset(suffix,0,sizeof(suffix));
for(int x=1;x<=n;x++){
prefix[x]=prefix[max(0,x-k)]+2*arr[x-1];
}
for(int x=n;x>=1;x--){
suffix[x]=suffix[min(n+1,x+k)]+2*(l-arr[x-1]);
}
int best=INT_MAX;
for(int x=0;x<=n;x++){
best=min(best,prefix[x]+suffix[x+1]);
}
for(int x=0;x<=n-k;x++){
best=min(best,prefix[x]+suffix[x+k+1]+l);
}
return best;
}
# | 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... |