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;
long long dp1[10000001];
long long dp2[10000001];
long long delivery(int n, int k, int l, int p[]) {
dp1[0] = 0;
dp2[n] = 0;
for(int i = 1; i <= n; i++) {
long long c = min(2*p[i-1],l);
if(i < k) {
dp1[i] = c;
}
else {
dp1[i] = c+dp1[i-k];
}
}
long long ans = LLONG_MAX;
for(int i = n-1; i >= 0; i--) {
long long c = min(2*(l-p[i]),l);
if(i > n-k) {
dp2[i] = c;
}
else {
dp2[i] = c+dp2[i+k];
}
}
for(int i = 0; i <= n; i++) {
ans = min(ans,dp1[i]+dp2[i]);
}
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... |