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 l[10000000];
long long r[10000000];
long long delivery(int N, int K, int L, int p[]) {
long long mn;
for(int i=0;i<K&&i<N;i++){
l[i]=p[i];
r[N-1-i]=L-p[N-1-i];
}
for(int i=K;i<N;i++){
l[i]=l[i-K]+p[i];
r[N-1-i]=r[N-1-i+K]+L-p[N-1-i];
}
for(int i=0;i<N;i++){
l[i]*=2;
r[i]*=2;
}
mn=min(l[N-1],r[0]);
for(int i=0;i<N-1;i++){
mn=min(mn,l[i]+r[i+1]);
}
if(K==N){
mn=min(mn,(long long)L);
}
mn=min(mn,L+r[min(K,N-1)]);
for(int i=0;i<N;i++){
mn=min(mn,l[i]+L+((i+K+1>=N)?0:r[i+K+1]));
}
return mn;
}
# | 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... |