Editorial for JDCC '15 Contest 1 P2 - Programming Elections
Submitting an official solution before solving the problem yourself is a bannable offence.
We have to find the maximum of two sets. We just go through the list and store the current highest of both genders. We need four variables, the name and number of votes of the so-far-best boy and girl candidates. If the number of votes of the current candidate exceeds the current winning candidate of that gender, then override both the number of votes and the name. After going through all the candidates, print the two winning candidates.
Time Complexity: , where is the number of candidates.