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;
const int MAXN = 1e7 + 10;
long long l[MAXN], r[MAXN];
long long delivery(int N, int K, int L, int p[]) {
long long n = N;
long long k = K;
for(int i = 0; i < N; i++){
l[i] = 2 * p[i];
if(i >= k) l[i] += l[i - k];
}
for(int i = N - 1; i >= 0; i--){
r[i] = 2 * (L - p[i]);
if(i + k < N) r[i] += r[i + k];
}
long long ans = 1e18;
for(int i = 0; i < N - 1; i++) ans = min(ans, l[i] + r[i + 1]);
ans = min(ans, l[n - 1]);
ans = min(ans, r[0]);
if(k == n) ans = min(ans, (long long)L);
else ans = min(ans, L + r[k]), ans = min(ans, l[n - k - 1] + L);
for(int i = 1; i + k < n; i++) ans = min(ans, l[i - 1] + L + r[i + k]);
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... |