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 <bits/stdc++.h>
#include "boxes.h"
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
#define pb emplace_back
ll delivery(int N, int K, int L, int p[]) {
ll pref[N + 2] = {};
ll suff[N + 2] = {};
for(int i = 1; i <= N; ++i) {
pref[i] = p[i - 1] * 2;
if(i > K)
pref[i] += pref[i - K];
}
for(int i = N; i >= 1; --i) {
suff[i] = (L - p[i - 1]) * 2;
if(i <= N - K)
suff[i] += suff[i + K];
}
ll ans = LLONG_MAX;
for(int i = 0; i <= N; ++i) {
ans = min(ans, pref[i] + suff[i + 1]);
}
for(int i = 0; i <= K; ++i) {
ans = min(ans, pref[i - K] + suff[i + 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... |