이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "boxes.h"
using namespace std;
using ll = long long;
ll delivery(int N, int K, int L, int p[]) {
vector<int>cep,sag;
int bnd = (L + 1) / 2;
for(int i = 0;i < N;i++){
if(p[i] <= bnd) cep.push_back(p[i]);
else sag.push_back(L - p[i]);
}
// return 100;
reverse(sag.begin(),sag.end());
vector<ll>cp_dp((int)cep.size());
vector<ll>sg_dp((int)sag.size());
int SZc = (int)cep.size();
int SZs = (int)sag.size();
for(int i = 0;i < SZc;i++){
if(i < K) cp_dp[i] = 2ll*cep[i];
else cp_dp[i] = 2ll*p[i] + cp_dp[i - K];
}
for(int i = 0;i < SZs;i++){
if(i < K) sg_dp[i] = 2ll*sag[i];
else sg_dp[i] = 2ll*p[i] + sg_dp[i - K];
}
// for(auto i : cep) cout<<i<<' ';
// cout<<'\n';
// for(auto i : sag) cout<<i<<' ';
// cout<<'\n';
ll ans = 0;
if(!cep.empty()) ans += cp_dp.back();
if(!sag.empty()) ans += sg_dp.back();
// cout<<cp_dp.back()<<' '<<sg_dp.back()<<'\n';
// return ans;
for(int i = 0;i <= min(K,SZc);i++){
ll nw = 0;
if(i != SZc) nw = cp_dp[SZc - i - 1];
ll now = nw;
int lft = K - i;
if(lft < SZs) now += sg_dp[SZs - lft - 1];
ans = min(ans,now + L);
lft = 2*K - i;
if(lft < SZs) nw += sg_dp[SZs - lft - 1];
ans = min(ans,nw + 2ll*L);
}
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... |