Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2014 /quals /basketball_game.html
wjomlex's picture
2014 Problems
718fd53 verified
raw
history blame
3.84 kB
<p>A group of <strong>N</strong> high school students wants to play a basketball game. To divide
themselves into two teams they first rank all the players in the following
way:<p>
<ul>
<li>Players with a higher shot percentage are rated higher than players with a lower
shot percentage.</li>
<li>If two players have the same shot percentage, the taller player is rated
higher.</li>
</ul>
<p>
Luckily there are no two players with both the same shot percentage and height
so they are able to order themselves in an unambiguous way. Based on that
ordering each player is assigned
a draft number from the range [1..<strong>N</strong>], where the highest-rated player gets the
number 1, the second highest-rated gets the number 2, and so on.
Now the first team contains all the players with the odd draft numbers and the
second team all the players with the even draft numbers.</p>
<p>
Each team can only have <strong>P</strong> players playing at a time, so to ensure that
everyone gets similar time on the court both teams will rotate their players
according to the following algorithm:</p>
<ul>
<li>Each team starts the game with the <strong>P</strong> players who have the lowest draft numbers.</li>
<li>If there are more than <strong>P</strong> players on a team after each minute of the game the player with the highest total
time played leaves the playing field. Ties are broken by the player with the higher draft number leaving first.</li>
<li>To replace her the player on the bench with the lowest total time played
joins the game. Ties are broken by the player with the lower draft number
entering first.</li>
</ul>
<p>
The game has been going on for <strong>M</strong> minutes now. Your task is to print out the
names of all the players currently on the field, (that is after <strong>M</strong> rotations).
</p>
<h3>Input</h3>
<p>
The first line of the input consists of a single number <strong>T</strong>, the number of test
cases.
</p>
<p>
Each test case starts with a line containing three space separated integers <strong>N</strong> <strong>M</strong> <strong>P</strong>
</p>
<p>
The subsequent <strong>N</strong> lines are in the format "&lt;name&gt; &lt;shot_percentage&gt; &lt;height&gt;".
See the example for clarification.
</p>
<h3>Constraints</h3>
<p>
1 &le; <strong>T</strong> &le; 50<br/>
2 * <strong>P</strong> &le; <strong>N</strong> &le; 30<br/>
1 &le; <strong>M</strong> &le; 120<br/>
1 &le; <strong>P</strong> &le; 5<br/>
Each name starts with an uppercase English letter, followed by 0 to 20 lowercase English letters. <br/>
There can be players sharing the same name. <br/>
Each shot percentage is an integer from the range [0..100]. <br/>
Each height is an integer from the range [100..240].
</p>
<h3>Output</h3>
<p>
For each test case <strong>i</strong> numbered from 1 to <strong>T</strong>, output "Case #<strong>i</strong>: ", followed by 2 * <strong>P</strong> space separated names of the players playing after <strong>M</strong> rotations. The names should be printed in lexicographical order.</p>
<h3>Example</h3>
<p>In the first example if you sort all the players by their shot percentage you get the list: [Wai, Purav, Weiyan, Slawek, Lin, Meihong]. This makes the two teams:</p>
[Wai, Weiyan, Lin]</br>
[Purav, Slawek, Meihong]</br>
<p>
The game starts with Lin and Meihong sitting on the bench in their respective teams. After the first minute passes it's time for Weiyan and Slawek to sit out since they have the highest draft numbers of the people who played. After the second minute passes Lin and Meihong will keep playing since they only played one minute so far and it's Wai and Purav who have to sit out.</p>
<p>Finally after the third minute Lin and Maihong go back to the bench
and all the players currently playing again are:<br/><samp>Purav Slawek Wai Weiyan</samp></p>