# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791970 | Josia | Boxes with souvenirs (IOI15_boxes) | C++17 | 2078 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 res = 0;
while (left.size() && right.size() && (left.back() + right.back())*2 > 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()) {
res += left.back()*2;
for (int i = 0; i<K; i++) {
if (left.size()) left.pop_back();
}
}
while (right.size()) {
res += right.back()*2;
for (int i = 0; i<K; i++) {
if (right.size()) right.pop_back();
}
}
}
Compilation message (stderr)
# | 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... |