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;
using ll=long long;
const ll LINF=(1LL<<60)-1LL;
long long delivery(int N, int K, int L, int p[]) {
ll res=LINF;
if(N>1000){
return 0;
}
sort(p,p+N);
int st=-1;
for(int i=0;i<N;i++){
if(p[i]>0){
st=i;
break;
}
}
if(st==-1){
return 0;
}
ll s=0;
for(ll i=st;i<N;i++){
ll t;
if((i-st+1)%K==0){
s+=2LL*p[i];
t=s;
}else{
t=s+2LL*p[i];
}
ll ss=0;
for(ll j=N-1;j>=i+1;j--){
ll tt;
if((N-j)%K==0){
ss+=2LL*(L-p[j]);
tt=ss;
}else{
tt=ss+2LL*(L-p[j]);
}
res=min(res,t+tt+L*((j-i-1)/K+((j-i-1)%K>0)));
}
}
return res;
}
# | 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... |