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;
}
vector<ll> sum(K);
for(ll i=st;i<N;i++){
sum[(i-st)%K]+=2LL*p[i];
vector<ll> sum2(K);
for(ll j=N-1;j>=i+1;j--){
sum2[(N-j-1)%K]+=2LL*(L-p[j]);
res=min(res,sum[(i-st)%K]+sum2[(N-j-1)%K]+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... |