Author: Andrew Seidel
At the local candy factory, every Tuesday, there is a contest for whoever can come up with the best new chocolate. To make a decision on whether or not each chocolate is a winner, there is a panel of impartial judges that come in from the community. The judges are given the following criteria for judging:
- Packaging (), up to point
- Flavour (), up to points
- Minimal ingredients (), up to points
A score is given to each chocolate from each judge assigned to that chocolate . There will be a random number of judges , assigned to each chocolate .
Your task is to declare the winner based on the highest total score in the competition. If there is a tie for the highest total score, it can sometimes be broken using the total scores for , and (try first, then , then ).
The competition is not really fair because some chocolates get more judges than others. But that's life at the candy factory.
Input Specification
The input will contain competitions. The first line of each competition will contain a single integer , to indicate the number of chocolates in the competition . For each of the chocolates, there will be lines in the file. The line is the name of the chocolate (a single word with no spaces) and the next lines will contain the judges' scores . Each score will be contained on a single line, starting with the letter J
followed by the integers , , and separated by spaces. Each competition ends with an asterisk *
(ASCII ).
Output Specification
Output the name of the winner. If there is more than one winner, print out all winners on a single line separated by commas (order does not matter — i.e., an output of A,B
is the same as B,A
).
Sample Input 1
2
C1
J 0 1 1
J 0 1 0
J 1 0 0
C2
J 1 2 3
*
Sample Output 1
C2
Note: Only case is shown in this sample.
Sample Input 2
4
ChocolateOfChocolates
J 0 2 2
J 0 1 2
J 1 2 0
Choco-Fun
J 1 2 3
J 1 2 0
ChocolateHaven
J 1 2 0
J 0 2 3
J 1 0 1
ChocolatesRock
J 1 2 1
J 1 2 0
J 1 2 0
*
1
ChocolateFilledCandy
J 0 0 0
*
Sample Output 2
ChocolateOfChocolates
ChocolateFilledCandy
Note: Only cases are shown in this sample.
Explanation of Sample 2
For the first competition, there is a tie between ChocolateOfChocolates
, ChocolateHaven
, and ChocolatesRock
. We then had to look at the values, which were tied for ChocolateOfChocolates
and ChocolateHaven
. Consequently, we had to then check the value. At this point, ChocolateOfChocolates
has the higher value.
ECOO 2017 Question Development Team
Kevin Forest ............................................... Sheridan College
John Ketelaars ....................................... ECOO-CS Communications
Stella Lau .......................................... University of Cambridge
Greg Reid .................. St. Francis Xavier Secondary School, Mississauga
Sam Scott .................................................... Mohawk College
Andrew Seidel ..................... John Fraser Secondary School, Mississauga
David Stermole ............................................ ECOO-CS President
Reyno Tilikaynen ..................................... University of Waterloo
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments