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 f first
#define s second
using namespace std;
const int N = 1e7 + 69;
long long dp1[N], dp2[N];
long long delivery(int n, int k, int l, int a[]) {
for (int i = 1;i <= n;i++)
dp1[i] = dp1[max(0, i - k)] + min(l, 2 * a[i - 1]);
for (int i = n;i >= 1;i--)
dp2[i] = dp2[min(n + 1, i + k)] + min(l, 2 * (l - a[i - 1]));
long long ans = min(dp1[n], dp2[1]);
for (int i = 1; i < n;i++)
ans = min(ans, dp1[i] + dp2[i + 1]);
return ans;
}
/*
3 2 8
1 2 5
*/
# | 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... |