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
const int N = 1e7+5;
const ll inf = 1e18;
ll dp1[N], dp2[N], ans=inf;
ll delivery(int n, int k, int L, int pos[]) {
for (int i=0; i<n; i++) dp1[i] = (ll)2*pos[i] + (i>=k ? dp1[i-k] : (ll)0);
for (int i=n-1; i>=0; i--) dp2[i] = (ll)2*(L-pos[i]) + (i<n-k ? dp2[i+k] : (ll)0);
for (int i=0; i<n-1; i++) ans = min(ans, dp1[i] + dp2[i+1]);
for (int i=0; i<n; i++) ans = min(ans, dp1[i] + (i+k+1<n ? dp2[i+k+1]:(ll)0) + (ll)L);
for (int i=k; i>=0; i--) ans = min(ans, dp2[i] + (ll)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... |