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 <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn=1e7+5;
ll dp1[maxn], dp2[maxn];
ll delivery(int n, int k, int l, int p[]) {
sort(p, p+n);
for(int i=0; i<n; i++){
dp1[i+1]=dp1[max(i+1-k, 0)]+p[i]*2;
}
for(int i=n-1; i>-1; i--){
dp2[i]=dp2[min(n, i+k)]+(l-p[i])*2;
}
ll mini=1e18;
for(int i=0; i<=n; i++){
mini=min(mini, dp1[i]+dp2[i]);
mini=min(mini, dp1[i]+dp2[min(n, i+k)]+l);
}
return mini;
}
# | 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... |