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 ll long long int
ll dp1[10000007];
ll dp2[10000007];
ll delivery(int n, int k, int l, int pos[])
{
for (int i = 1;i <= n;i++) dp1[i]= dp1[max(0,i - k)] + 2 * pos[i - 1];
for (int i= n;i >= 1;i--) dp2[i]= dp2[min(n + 1,i + k)] + 2 * (l - pos[i - 1]);
ll ans=1e18;
for (int i = 1;i <= n + 1;i++) ans = min(ans, dp1[i - 1] + dp2[i]);
for (int i = k;i <= n;i++) ans = min(ans,dp1[i - k] + dp2[i + 1] + 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... |