이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
int n, k, l;
vector<int> lhalf, rhalf;
int lsize, rsize;
vector<lld> beg_l, beg_r;
long long delivery(int N, int K, int L, int p[]){
lld cost = 1e18;
n = N; k = K; l = L;
if(n==1) return min((lld)2*p[0], (lld)2*(l-p[0]));
for(int i=0;i<n&&2*p[i]<=l;i++){
lhalf.push_back(p[i]);
}
lsize = (int) lhalf.size();
for(int i=n-1;i>=0&&2*(l-p[i])<l;i--){
rhalf.push_back(l-p[i]);
}
rsize = (int) rhalf.size();
beg_l.push_back(0);
for(int i=0;i<lsize;i++){
beg_l.push_back(2*((lld)lhalf[i])+beg_l[max(0, i-k+1)]);
}
beg_r.push_back(0);
for(int i=0;i<rsize;i++){
beg_r.push_back(2*((lld)rhalf[i])+beg_r[max(0, i-k+1)]);
}
for(int i=0;i<rsize+1;i++){
for(int j=0;j<lsize+1;j++){
if((n-i-j)%k==0){
cost = min(cost, ((lld)((n-i-j)/k))*((lld)l)+beg_l[j]+beg_r[i]);
}
}
}
return cost;
}
# | 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... |