이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
#include <set>
long long delivery(int numTeams, int capacity, int numSections, int p[])
{
auto DistTo0 = [&] (int x)
{
return std::min(x, numSections - x);
};
int numL = 0;
int numR = 0;
std::vector<int> numTeamsPerSection(numSections);
std::set<int> teamPositions;
for (int i = 0; i < numTeams; i++)
{
if (p[i] != 0)
{
numTeamsPerSection[p[i]]++;
if (p[i] * 2 < numSections)
numL++;
else
numR++;
}
}
long long sec = 0;
while (numL > 0 || numR > 0)
{
int boxes = capacity;
int pos = 0;
int dir;
if (numR > numL)
{
dir = -1;
}
else
{
dir = 1;
}
while (true)
{
if (pos != 0)
{
int numToGive = std::min(numTeamsPerSection[pos], boxes);
numTeamsPerSection[pos] -= numToGive;
boxes -= numToGive;
if (pos * 2 < numSections)
numL -= numToGive;
else
numR -= numToGive;
if (boxes <= 0 || (numL == 0 && numR == 0))
{
sec += DistTo0(pos);
break;
}
}
pos += dir;
sec++;
if (pos == 0 || pos == numSections)
break;
if (pos == -1)
pos = numSections - 1;
}
}
return sec;
}
| # | 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... |