#include <bits/stdc++.h>
// mrrrow meeow :3
// go play vivid/stasis now! it's free on steam
#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;
int ____init = [] {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
return 0;
}();
long long dp[10000000];
long long delivery(int n, int k, int l, int positions[]) {
int halfl = l / 2;
int halfr = (l + 1) / 2;
fo(i, 1, k) dp[i] = positions[i - 1] * 2;
long long res = 100000000000000;
fo(i, 0, n) {
if (positions[i] <= halfl) {
if (positions[min(i + k - 1, n - 1)] >= halfr) {
if (i + k >= n) res = min(res, dp[i] + l);
else dp[i + k] = dp[i] + l;
} else {
if (i + k >= n) res = min(res, dp[i] + positions[min(i + k - 1, n - 1)] * 2);
else dp[i + k] = dp[i] + positions[i + k - 1] * 2;
}
} else {
if (i + k >= n) res = min(res, dp[i] + (l - positions[i]) * 2);
else dp[i + k] = dp[i] + (l - positions[i]) * 2;
}
}
return res;
}
# | 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... |