Picking the Best of Several Classes
Halyard Mail has outgrown two labels. A message can now be filed under any number of them -- promotions, notifications, spam, the rest -- and the filter has already produced one score per label. Bigger is better on this scale, and the scores can come back negative, positive or a mix of the two in the same run, so the sign carries no meaning of its own. What Halyard cares about beyond the answer is that the answer be reproducible: when two labels finish exactly level, the file the message lands in must not depend on the order the labels happened to arrive in.
Task: Print the label the filter files this message under.
Input
The first line holds one integer n, the number of labels. Each of the next n lines holds a label and its score, separated by a single space; a label contains no spaces.
Output
One line holding the label with the highest score. If several labels share the highest score, print whichever of them comes first alphabetically.
Example:
Input:
3
spam -6.2
ham -9.0
promo -5.5
Output:
promo
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in