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<cstdio>
#include<algorithm>
long long a,i,mini,left[10000006],right[10000006];
long long min(long long XX,long long YY){return XX>YY?YY:XX;}
long long delivery(int N,int K,int L,int positions[])
{
for(i=0;i<N;i++)
{
left[i]=positions[i]<=L/2?positions[i]*2:L;
if(i+1>K)
{
left[i]+=left[i-K];
}
}
for(i=N-1;i>=0;i--)
{
right[i]=(L-positions[i])<=L/2?(L-positions[i])*2:L;
if(N-i>K)
{
right[i]+=right[i+K];
}
}
mini=min(left[N-1],right[0]);
for(i=1;i<N-1;i++)
{
mini=min(mini,left[i]+right[i+1]);
}
return mini;
}
# | 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... |