IOI Selection
Time limit1sMemory limit1024 MB
Given each participant's four raw contest scores and school year, normalize scores per contest, sum the final plus the two best KATT results, then pick the IOI and BOI teams.
- Level
Medium5 of 10
- Topics
- Sorting, Implementation, Math, Simulation
- Solved
- No attempts yet
Problem
The organizing group of the Programming Olympiad wants to go out and play in the snow. Unfortunately, as organizers they have countless duties that come before playing. They have to write problems, supervise contests, travel as team leaders, and compute which participants are selected for the national team based on this year's results.
It occurred to the organizers, however, that the last part could be handled by someone else. For example, you.
The rules for national team selection are as follows. In total there are four contests that form the basis for selection: the final contest and three so-called KATT contests (KATT1, KATT2 and KATT3).
After all contests, the results are added up, and the four contestants with the best scores are selected for the International Olympiad in Informatics, IOI. In addition to IOI, a team must also be chosen for the Baltic Olympiad in Informatics, BOI. This team consists of the IOI team plus the two best contestants who are not in year 9 and did not qualify for IOI.
When the results are added up, the two best results from the three KATT contests are chosen, along with the result from the final, and summed.
Within a contest, the result is computed by normalizing the score a contestant received. First, the best score among all participants and the median score among all participants are computed. If a contestant received points, the contestant's result is . If a contestant received points, the contestant's result is . This means the result increases linearly from 0 to 50 as the score increases from 0 to , and from 50 to 100 as the score increases from to .
For each participant in the contest, you will be given the participant's result in the four contests, as well as the participant's year. Determine who is selected for IOI and BOI.
Input
The first line contains an integer , the number of participants.
The next lines describe a participant and their results. A line begins with the participant's name, which consists of up to 20 lowercase letters from to , with no spaces. Then follows a number that is either and describes the participant's year. The years represent here students in lower secondary school. Finally come four integers , the scores from the final, KATT1, KATT2 and KATT3 respectively.
In a contest, the median and the maximum score will always be different from each other. There will always be exactly one possible team according to the rules above.
Output
On the first line, print the names of the four participants who were selected for IOI.
The next line must contain two names: the additional participants who qualified for BOI.
On each line, the names you print must be sorted in alphabetical order.