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 <algorithm>
#include <cstdio>
long long prefix[10000000];
long long suffix[10000000];
long long delivery(int N, int K, int L, int p[]) {
for(int i=1;i<=N;i++){
prefix[i]=((i>=K)?prefix[i-K]:0)+2*p[i-1];
}
for(int i=N;i>=1;i--){
suffix[i]=((i+K<=N+1)?suffix[i+K]:0)+2*(L-p[i-1]);
}
long long ans=1e18;
for(int i=1;i<=N+1;i++){
ans=std::min(ans,prefix[i-1]+suffix[i]);
}
for(int i=1;i+K<=N+1;i++){
ans=std::min(ans,prefix[i-1]+suffix[i+K]+L);
}
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... |