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;
typedef long long int ll;
int n,k,l;
int cl=1,ch=1;
ll dpl[10000001]={},dph[10000001]={};
long long delivery(int N, int K, int L, int p[]) {
n=N;
k=K;
l=L;
for(int i=0;i<n;i++)
{
if(p[i]==0) continue;
if(p[i]<=l/2)
{
dpl[cl]=(ll)p[i];
dpl[cl]+=(cl>=k? dpl[cl-k]:0);
cl++;
}
else
{
dph[ch]=(ll)(l-p[i]);
ch++;
}
}
ll temp;
for(int i=1;i<(ch+1)/2;i++)
{
temp=dph[i];
dph[i]=dph[ch-i];
dph[ch-i]=temp;
}
for(int i=k;i<ch;i++)
{
dph[i]+=dph[i-k];
}
ll ans=2*(dph[ch-1]+dpl[cl-1]);
for(int i=0;i<=k;i++)
{
ans=min(ans,(ll)l+2*(dph[max(ch-1-i,0)]+dpl[max(cl-1-(k-i),0)]));
}
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... |