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;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#include "boxes.h"
llo dp[10000001];
long long delivery(int n, int k, int ll, int it[]) {
sort(it,it+n);
for(int i=0;i<n;i++){
dp[i]=-1;
}
llo l=ll;
for(int i=0;i<n;i++){
for(int j=max(0,i-k+1);j<=i;j++){
llo cost=l;
cost=min(cost,it[i]*(llo)2);
cost=min(cost,(l-it[j])*(llo)2);
if(j>0){
cost+=dp[j-1];
}
if(dp[i]==-1){
dp[i]=cost;
}
dp[i]=min(dp[i],cost);
}
}
return dp[n-1];
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
return 0;
}*/
/*
g++ -o aa -O2 box.cpp grader.cpp -std=c++14
*/
# | 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... |