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;
#define pb push_back
long long delivery(int n, int k, int l, int p[]){
vector<int>pos;
for(int i = 0; i < n; i++){
pos.pb(p[i]);
}
vector<long long>ldp(n + 10), rdp(n + 10);
for(int i = 1; i <= n; i++){
ldp[i] = ldp[max(i - k, 0)] + pos[i - 1] * 2;
}
for(int i = n; i >= 1; i--){
rdp[i] = rdp[min(i + k, n + 1)] + (l - pos[i - 1]) * 2;
}
long long ans = 8e18;
for(int i = 0; i <= n; i++){
ans = min(ans, ldp[i] + rdp[i + 1]);
}
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... |