# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
674834 | benjaminkleyn | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 240 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 <bits/stdc++.h>
#include "boxes.h"
using namespace std;
typedef long long ll;
ll delivery(int n, int k, int l, int p[])
{
vector<ll> L, R;
for (int i = 0; i < n; i++)
if (l - p[i] < p[i])
L.push_back(l - p[i]);
else
R.push_back(p[i]);
sort(L.rbegin(), L.rend());
sort(R.rbegin(), R.rend());
ll ans = 0;
while (L.size() >= k)
{
for (int i = 0; i < k - 1; i++)
L.pop_back();
ans += 2 * L.back();
L.pop_back();
}
while (R.size() >= k)
{
for (int i = 0; i < k - 1; i++)
R.pop_back();
ans += 2 * R.back();
R.pop_back();
}
if (L.size() == 0)
ans += 2 * R.back();
else if (R.size() == 0)
ans += 2 * L.back();
else if (L.size() + R.size() <= k)
ans += l;
else
ans += l + min(R[k - L.size()], L[k - R.size()]);
return ans;
}
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... |