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>
using namespace std;
int posl[10000100];
int posr[10000100];
int cntl;
int cntr;
long long dpl[10000100];
long long dpr[10000100];
long long delivery(int N, int K, int L, int p[]) {
int m=L/2;
for (int i=0;i<N;i++) {
if (p[i]<=m) {
posl[cntl++]=p[i];
} else {
posr[cntr++]=L-p[i];
}
}
reverse(posr,posr+cntr);
for (int i=0;i<min(cntl,K);i++) {
dpl[i]=posl[i]*2;
}
for (int i=K;i<cntl;i++) {
dpl[i]=dpl[i-K]+posl[i]*2;
}
for (int i=0;i<min(cntr,K);i++) {
dpr[i]=posr[i]*2;
}
for (int i=K;i<cntr;i++) {
dpr[i]=dpr[i-K]+posr[i]*2;
}
long long ans=1e16;
int x;
if (cntl<=K) x=cntl-1;
else x=K;
for (int i=0;i<=x;i++) {
ans=min(ans,dpl[cntl-i-1]+((cntr-(K-i)-1<0)?0:dpr[cntr-(K-i)-1])+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... |