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 ll, int p[]) {
int l = -1 ;
int r = N ;
long long ans = 1e18 ;
long long L = ll ;
while(l + 1 < r){
int m = (l + r) / 2 ;
if(p[m] <= L / 2) l = m ;
else r = m ;
}
for(long long i = 0 ; i <= N ; i ++){
long long s = 0 ;
for(int j = l ; j >= 0 ; j = j - K)
s = s + 2ll * p[j];
for(int j = r ; j < N ; j = j + K)
s = s + 2ll * (L - p[j]);
ans = min(ans , i * L + s);
for(int j = 1 ; j <= K ; j ++){
if(l >= 0 && r < N){
if(L / 2 - p[l] <= p[r] - L / 2){
l -- ;
}
else r ++ ;
}
else if(l >= 0)
l -- ;
else if(r < N)
r ++ ;
}
}
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... |