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;
using ll = long long;
long long delivery(int N, int K, int L, int p[]) {
ll pref[N], suf[N];
for(int i = 0; i < N; ++i){
pref[i] = p[i] * 2 + (i >= K ? pref[i - K] : 0);
}
for(int i = N - 1; i >= 0; --i){
suf[i] = (L - p[i]) * 2 + (i + K < N ? suf[i + K] : 0LL);
}
ll ans = min(pref[N - 1], suf[0]);
for(int i = 0; i + 1 <N; ++i) ans = min(ans, pref[i] + suf[i + 1]);
for(int i = 0; i < N; ++i){
ll curr = L;
if(i) curr += pref[i - 1];
if(i + K < N) curr += suf[i + K];
ans = min(ans, curr);
}
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... |