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>
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int MAXN = 1e7 + 5;
int N, K, L;
ll pre[MAXN], suf[MAXN];
ll delivery(int _n, int _k, int _l, int p[])
{
N = _n, K = _k, L = _l;
for(int i = 0; i < N; i++)
pre[i] = (i - K >= 0 ? pre[i - K] : 0) + 2*p[i];
for(int i = N - 1; i >= 0; i--)
suf[i] = (i + K < N ? suf[i + K] : 0) + 2*(L-p[i]);
ll ans = min(min(pre[N - 1], suf[0]), min(L + suf[K], pre[N - K - 1] + K));
for(int i = 0; i < N - 1; i++)
ans = min(ans, pre[i] + suf[i + 1]);
for(int i = 0; i < N - K - 1; i++)
ans = min(ans, pre[i] + suf[i + K + 1] + 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... |