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>
#include "boxes.h"
using namespace std;
typedef long long ll;
ll delivery(int N, int K, int L, int p[]){
sort(p,p+N);
vector<ll> left(N+1,0),right(N+1,0);
for(int i=0;i<N;i++){
if(i<K){
left[i+1]=min(p[i]*2,L);
}else{
left[i+1]=min(p[i]*2,L)+left[i+1-K];
}
}
for(int i=0;i<N;i++)p[i]=L-p[i];
sort(p,p+N);
for(int i=0;i<N;i++){
if(i<K){
right[i+1]=min(p[i]*2,L);
}else{
right[i+1]=min(p[i]*2,L)+right[i+1-K];
}
}
ll ans=LLONG_MAX;
for(int i=0;i<N+1;i++)ans=min(ans,left[i]+right[N-i]);
// for(int i=0;i<N+1;i++)cout << left[i] << ' ';
// cout << '\n';
// for(int i=0;i<N+1;i++)cout << right[i] << ' ';
// cout << '\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... |