이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include<bits/stdc++.h>
using namespace std ;
pair<long long , long long> dppred[10000001] , dpfirst[10000001];
long long delivery(int N, int K, int L, int p[]) {
int l = 0 ;
int r = N - 1 ;
long long ans = 1e18 ;
while(l + 1 < r){
int m = (l + r) / 2 ;
if(p[m] <= L / 2) l = m ;
else r = m ;
}
for(int i = 0 ; i <= N ; i ++){
long long s = 0 ;
for(int j = l ; j >=0 ; j -= K)
s = s + 2 * p[j];
for(int j = r ; j < N ; j += K)
s = s + 2 * (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... |