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;
long long delivery(int N, int K, int L, int p[]) {
long long ans = 1e18;
vector<long long> pref(N, 0);
vector<long long> suf(N, 0);
for(int i = 0; i < N; i++) {
if(i >= K) {
pref[i] = pref[i - K];
}
pref[i] += p[i] * 2;
}
for(int i = N - 1; i >= 0; i--) {
if(i + K < N) {
suf[i] = suf[i + K];
}
suf[i] += (L - p[i]) * 2;
}
for(int i = 0; i < N - 1; i++) {
ans = min(ans, pref[i] + suf[i + 1]);
}
return ans;
}
/*
int main() {
int X[3] = {1, 2, 5};
cout << delivery(3, 2, 8, X);
}*/
# | 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... |