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<iostream>
#include "boxes.h"
using namespace std;
#define MAX 100000000000000000
long long maone[10000005],maoneri[10000005],maonele[10000005];
long long delivery(int N, int k, int L, int p[]) {
long long ans=MAX;
for(int i=1;i<=N;i++)
maonele[i]=maonele[max(0,i-k)]+2*p[i-1];
for(int i=N;i>=1;i--){
maoneri[i]=maoneri[min(N+1,i+k)]+2*(L-p[i-1]);
}
for(int i=1;i<=N;i++)
{
maone[i]=min(maonele[i],maoneri[i]);
ans=min(ans,maonele[i-1]+maoneri[i]);
}
for(int i=max(N/2-k,1);i<=min(N/2+k,N);i++)
{
ans=min(ans,maone[max(0,i-k)]+maone[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... |