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;
int sL[10000005], brL=0, tL=0;
int sR[10000005], brR=0, tR=0;
long long dpL[10000005];
long long dpR[10000005];
long long delivery(int N, int K, int L, int p[])
{
for(int i=0; i<N; i++)
{
if(p[i]==0) continue;
if(p[i]<=L/2) sL[brL]=p[i], brL++;
else sR[brR]=p[i], brR++;
}
sort(sL, sL+brL);
sort(sR, sR+brR);
reverse(sR, sR+brR);
for(int i=0; i<brL; i++)
{
dpL[i]=2*sL[i];
if(i>=K) dpL[i]+=dpL[i-K];
}
for(int i=0; i<brR; i++)
{
dpR[i]=2*(L-sR[i]);
if(i>=K) dpR[i]+=dpR[i-K];
}
long long mans=1e18;
if(brL%K==0 || brR%K==0) return dpL[brL-1]+dpR[brR-1];
for(int i=1; i<=K-1; i++)
{
if(brL<i || brR<K-i) continue;
long long ch=L;
if(brL>i) ch+=dpL[brL-1-i];
if(brR>K-i) ch+=dpR[brR-1-K+i];
mans=min(mans, ch);
}
return mans;
}
# | 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... |