#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forsn(i, s, n) for (int i = int(s); i < int(n); i++)
#define dforn(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define dforsn(i, s, n) for (int i = int(n) - 1; i >= int(s); i--)
using vi = vector<int>;
using ll = long long;
using ii = pair<int, int>;
#define fst first
#define snd second
#define all(x) begin(x), end(x)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
const ll INF = 6e18;
ll delivery(int N, int K, int L, int p[]) {
vector<ll> pref(N + 1);
forn(i, N) {
pref[i + 1] = pref[max(0, i + 1 - K)] + 2LL * p[i];
}
vector<ll> suff(N + 1);
dforn(i, N) {
suff[i] = suff[min(i + K, N)] + 2LL * (L - p[i]);
}
ll ret = INF;
forn(t, 2) forn(i, N + 1) {
ret = min(ret, pref[i] + 1LL * t * L + suff[min((ll) N, i + 1LL * t * K)]);
}
return ret;
}
# | 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... |