Vote
Time limit2sMemory limit512 MB
Sum each candidate's results across vote centers and report the unique top scorer, or a dilemma if there is a tie.
- Level
Easy3 of 10
- Topics
- Hash map, Implementation, Sorting
- Solved
- No attempts yet
Problem
Benin holds a presidential election on 6 March 2016. Several candidates registered, and the national electoral commission, the CENA (Commission Nationale Electorale Autonome), runs the election.
Under Article 15 of the Beninese electoral code, the CENA prepares and organizes the election, supervises the voting, and centralizes the results.
Partial results arrive from the vote centers. Write a program that centralizes them and reports the winner of each election.
Input
The first line contains the number of data sets ().
Each data set starts with a line containing the number of candidates () and the number of results to centralize (), separated by a space. The next lines contain the names of the candidates, one per line. The next lines each contain the name of a candidate, the result of that candidate, and the name of the vote center, separated by spaces.
and are strings without whitespace of at most 1000 characters. is an integer with . Within one data set the candidate names are distinct and every is one of the candidates. The same candidate may appear in several result lines, one per vote center, and a candidate with no result line has the total 0.
Output
Print one line for each data set. If exactly one candidate has the greatest total, print VOTE i: THE WINNER IS followed by the name of that candidate, a space, and that candidate's total. Otherwise print VOTE i: THERE IS A DILEMMA. Here is the number of the data set, counted from 1.