This content is archived!
For the 2018-2019 school year, we have switched to using the WLMOJ judge for all MCPT related content. This is an archive of our old website and will not be updated.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
\mathcal{O}(N), where N is the number of candidates.