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)pos[i] + (i>=k ? dp1[i-k] : 0) + (ll)min(pos[i], L-pos[i]);
for (int i=n-1; i>=0; i--) dp2[i] = (ll)(L-pos[i]) + (i+k<n ? dp2[i+k] : 0) + (ll)min(pos[i], L-pos[i]);
for (int i=0; i<n-1; i++) ans = min(ans, dp1[i] + dp2[i+1]);
ans = min(ans, min(dp1[n-1], dp2[0]));
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... |