이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
long long delivery(signed N, signed K, signed L, signed p[]) {
vector<int> left, right;
for (int i = 0; i<N; i++) {
if (p[i] < L/2) left.push_back(p[i]);
else right.push_back(L-p[i]);
}
sort(left.begin(), left.end());
sort(right.begin(), right.end());
auto leftO = left;
auto rightO = right;
long long res1 = L;
for (int i = 0; i<K; i++) {
if ((left.size() && right.empty()) || (left.size() && left.back() > right.back())) {
left.pop_back();
} else if (right.size()) {
right.pop_back();
}
}
while (left.size()) {
res1 += left.back()*2;
for (int i = 0; i<K; i++) {
if (left.size()) left.pop_back();
}
}
while (right.size()) {
res1 += right.back()*2;
for (int i = 0; i<K; i++) {
if (right.size()) right.pop_back();
}
}
left = leftO;
right = rightO;
long long res2 = 0;
while (left.size()) {
res2 += left.back()*2;
for (int i = 0; i<K; i++) {
if (left.size()) left.pop_back();
}
}
while (right.size()) {
res2 += right.back()*2;
for (int i = 0; i<K; i++) {
if (right.size()) right.pop_back();
}
}
return min(res1, res2);
}
# | 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... |