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 delivery(int N, int K, int L, int p[]) {
sort(p,p+N);
long long arr[N],brr[N],crr[N],drr[N];
int st=0;
while(p[st]==0){
st++;
if(st==N){
return 0;
}
}
for(int i=st;i<N;i++){
arr[i]=min(p[i]*2,L);
crr[i]=arr[i];
if(i-K>=st){
crr[i]+=crr[i-K];
}
}
for(int i=N-1;i>=st;i--){
brr[i]=min((L-p[i])*2,L);
drr[i]=brr[i];
if(i+K<=N-1){
drr[i]+=drr[i+K];
}
}
long long ans=min(drr[st],crr[N-1]);
//cout << drr[st] << '\n';
for(int i=st;i<N-1;i++){
//cout << crr[i]+drr[i+1] << '\n';
ans=min(ans,crr[i]+drr[i+1]);
}
//cout << crr[N-1] << '\n';
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... |