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;
long long delivery(int n, int k, int L, int positions[]) {
vector<long long>l(n+1),r(n+1);
l[0] = r[0] = 0;
for(int i = 1 ; i <= n ; i++) {
int p = max(0, i - k);
l[i] = l[p] + (long long)2*(positions[i-1]);
r[i] = r[p] + (long long)2*(L - positions[n - i]);
//cout << l[i] << ' ' << r[i] << '\n';
}
long long ans = (long long)1e18;
for(int i = 0 ; i <= n ; i++) {
ans = min(ans, l[i] + r[n-i]);
ans = min(ans, l[i] + r[min(n, n-i + k)] + L);
//cout << i << ' ' << ans << '\n';
}
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... |