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>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll s1[10000100],s2[10000100];
long long delivery(int N, int K, int L, int p[]) {
for(int i=1;i<=N;i++){//[0,i)
int j=max(0,i-K);//[j,i)
ll cost=min(p[i-1],L-p[i-1])+min(p[j],L-p[j])+abs(p[i-1]-p[j]);
s1[i]=s1[j]+cost;
}
for(int i=N-1;i>=0;i--){//[i,N)
int j=min(N,i+K);//[i,j)
ll cost=min(p[i],L-p[i])+min(p[j-1],L-p[j-1])+abs(p[i]-p[j-1]);
s2[i]=s2[j]+cost;
}
ll Min=INF;
for(int i=0;i<=N;i++){
Min=min(Min,s1[i]+s2[i]);
}
return Min;
}
# | 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... |