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>
using namespace std;
int N, K, L;
long long CW[10000005];
long long CCW[10000005];
int P[10000005];
long long delivery (int n, int k, int l, int p[]){
N = n, K = k, L = l;
for (int i=1; i<=N; i++) P[i] = p[i-1];
for (int i=1; i<=N; i++){
int j = max(i-K, 0);
CW[i] = CW[j] + P[i] + min(L-P[i], P[i]);
}
for (int i=N; i>0; i--){
int j = min(N+1, i+K);
CCW[i] = CCW[j] + L - P[i] + min(L - P[i], P[i]);
}
long long ans = 9e18;
for (int i=1; i<=N; i++){
ans = min(ans, CW[i] + CCW[i+1]);
}
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... |