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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
#define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--)
#define rep(i, n) ffor(i, 0, n)
#define forin(x, a) for (auto &x: a)
#define all(a) a.begin(), a.end()
long long delivery(int N, int K, int L, int p[]) {
if (p[N - 1] == 0) {
return 0;
}
function<ll(ll, int, int, int, int)> search;
search = [&](ll curr, int pos, int rem, int l, int r) {
if (l == r) {
return curr + min(pos, L - pos);
}
if (rem == 0) {
return search(curr + min(pos, L - pos), 0, K, l, r);
}
return min(search(curr + (p[l] - pos + L) % L, p[l], (pos <= p[l] ? rem - 1 : K - 1), l + 1, r), search(curr + (pos - p[r - 1] + L) % L, p[r - 1], (pos >= p[r - 1] ? rem - 1 : K - 1), l, r - 1));
};
int a = 0;
while (!p[a]) {
a++;
}
return search(0, 0, K, a, N);
}
# | 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... |