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];
pref[i] += min(2ll*p[i], 1ll*l);
}
for (int i = n-1; i >= 0; --i) {
if (i + k < n) suf[i] = suf[i+k];
suf[i] += min(2ll*(l - p[i]), 1ll*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... |