이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
vector<int> v;
for(int i = 0; i < N; i++){
v.emplace_back(min(p[i],L-p[i]));
}
sort(v.begin(),v.end());
deque<int> dq;
vector<long long> dp;
dp.resize(N);
dp[0] = 2ll*v[0];
dq.push_back(0);
long long mn = (long long)(N+K-1)/(long long)K*(long long)L;
for(int i = 1; i < N; i++){
mn = min(mn,dp[i-1] + (long long)(N-i+K-1)/(long long)K*(long long)L);
while(!dq.empty() && i - dq.front() >= K) dq.pop_front();
dp[i] = dp[dq.front()] + 2ll*(long long)v[i];
while(!dq.empty() && dp[i] < dp[dq.back()]) dq.pop_back();
dq.push_back(i);
}
mn = min(mn,dp[N-1]);
return mn;
}
# | 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... |