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;
using ll = long long;
const int N = 1e7+10;
int n, k; ll l;
ll dp1[N], dp2[N];
long long delivery(int _n, int _k, int _l, int p[]) {
n = _n, k = _k, l = _l;
for(int i = 1; i <= n; i++) {
dp1[i] = 2ll * p[i - 1] + (i - k ? dp1[i - k] : 0);
dp2[i] = 2ll * (l - p[n - i]) + (i - k ? dp2[i - k] : 0);
}
ll ans = 1e18;
for(int i = 0; i <= n; i++) {
ans = min(ans, dp1[i] + dp2[n - i]);
if(n - i - k >= 0)
ans = min(ans, dp1[i] + dp2[n - i - k] + 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... |