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;
const long long INF=LLONG_MAX;
long long delivery(int n, int k, int l, int p[]) {
vector<long long> left(n+1);
left[0]=0;
for(int i=0; i<n; i++){
long long distance = min(p[i], l-p[i]);
left[i+1] = left[max(0, i+1-k)] + distance + p[i];
}
vector<long long> right(n+1);
right[0]=0;
for(int i=0; i<n; i++){
long long distance = min(p[i], l-p[i]);
right[i+1] = right[max(0, i+1-k)] + distance + l-p[i];
}
long long ans=INF;
for(int i=0; i<=n; i++){
ans = min(ans, left[i] + right[n-i]);
}
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... |