이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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)
{
minRes = min(minRes, compute(teams, k) + compute(side, k) + l);
if (!teams.empty()) teams.pop_back();
if (!left.empty())
{
side.push_back(left.back());
left.pop_back();
}
}
return minRes;
}
# | 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... |