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"
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
long long delivery(int n, int k, int L, int pos[]) {
vl pref(n),suf(n);
for (int i = 0;i<n;i++)pref[i] = 1ll * 2 * 1ll * pos[i] + (i >= k ? pref[i - k] : 0);
for (int i = n - 1;i>=0;i--)suf[i] = 1ll * 2 * 1ll * (1ll * L - 1ll * pos[i]) + (i + k < n ? suf[i + k] : 0);
ll ans = min(pref[n - 1],suf[0]);
for (int i = 0;i<n - 1;i++)ans = min(ans,pref[i] + suf[i + 1]);
for (int i = 0;i<n;i++)
ans = min(ans,(i >= 1 ? pref[i - 1] : 0) + (i + k < n ? suf[i + k] : 0) + L);
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... |