# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
537829 | timreizin | Boxes with souvenirs (IOI15_boxes) | C++17 | 809 ms | 334148 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 <vector>
using namespace std;
using ll = long long;
ll compute(vector<ll> &a, int k)
{
ll res = 0;
for (int i = (int)a.size() - 1; i >= 0; i -= k) res += a[i] * 2;
return res;
}
long long delivery(int n, int k, int l, int P[])
{
vector<ll> teams(n);
for (int i = 0; i < n; ++i) teams[i] = P[i];
vector<ll> side, left;
while (!teams.empty() && l - teams.back() < teams.back())
{
side.push_back(l - teams.back());
teams.pop_back();
}
ll minRes = compute(teams, k) + compute(side, k);
for (int i = 0; i < k && !side.empty(); ++i)
{
left.push_back(side.back());
side.pop_back();
}
for (int i = 0; i <= k; ++i)
{
if (k - i < left.size())
{
side.push_back(left.back());
left.pop_back();
}
minRes = min(minRes, compute(teams, k) + compute(side, k) + l);
if (!teams.empty()) teams.pop_back();
}
return minRes;
}
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... |