이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll delivery(int N_, int K_, int L_, int p[])
{
ll L = L_; ll N = N_; ll K = K_;
deque<ll> v(N);
for (int i = 0; i < N; i++)
v[i] = p[i];
sort(v.begin(), v.end());
ll res = 0;
while (v.size())
{
ll indexLeft = max((ll)v.size() - K, 0ll);
ll indexRight = min((ll)v.size() - 1, K - 1);
if (v[indexLeft] > L / 2)
{
res += (L - v[indexLeft]) * 2;
for (int i = 0; i < K && v.size(); i++)
v.pop_back();
}
else if (v[indexRight] <= L / 2)
{
res += v[indexLeft] * 2;
for (int i = 0; i < K && v.size(); i++)
v.pop_front();
}
else
{
res += L * ((v.size() + K - 1) / K);
break;
}
}
return res;
}
# | 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... |