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 <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define oo 1000000000000000000ll
long long delivery(int n, int k, int l, int p[]) {
vector<ll> pref(n), suf(n+1);
for (int i = 0; i < n; ++i) {
if (i - k >= 0) pref[i] = pref[i-k];
if (p[i] < l/2) pref[i] += 2ll*p[i];
else pref[i] += l;
}
for (int i = n-1; i >= 0; --i) {
if (i + k < n) suf[i] = suf[i+k];
if (p[i] > l/2) suf[i] += 2ll*(l - p[i]);
else suf[i] += l;
}
ll ans = suf[0];
for (int i = 0; i < n; ++i) {
ans = min(ans, pref[i] + suf[i+1]);
}
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... |