WC '16 Contest 2 J1 - The Perfect Mate

View as PDF

Submit solution


Points: 3
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
Woburn Challenge 2016-17 Round 2 - Junior Division

Lieutenant B'Elenne Terres is one unsatisfied Klingon. Her engineering working aboard the Starship Enterprise is all well and good, but what she really needs is a mate!

Fortunately for her, the Enterprise has happened across a Klingon colony, which has N (1 \le N \le 100) warriors living there. The i^{th} warrior's name is S_i (a unique string consisting of at most 20 letters), and according to a survey which Terres has conducted, they've won W_i (0 \le W_i \le 100) battles and lost L_i (0 \le L_i \le 100) battles in their lifetime. She's not too concerned about which of the warriors actually happen to be single at the time.

Any warrior who has lost at least one battle would clearly not make a suitable mate - weakness is unacceptable. Of the warriors who have never lost any battles, the perfect mate is the one who has won the greatest number of battles. If multiple suitable warriors have won the same number of battles, then the one earliest in the list of N warriors is preferable.

Please help Terres determine the name of this perfect mate! Of course, it's also possible that there's no such mate, if none of the N warriors are suitable.

Input Specification

The first line of input consists of a single integer N.
N lines follow, with the i^{th} of these lines consisting of a single string S_i, followed by a space, followed by two space-separated integers W_i and L_i (for i = 1 \dots N).

Output Specification

Output a single line consisting of a single string - either the name of the perfect mate, or None if there are no suitable mates.

Sample Input 1

5
Mereg 7 0
Werf 15 10
Kehless 14 0
Kerek 14 0
Stex 2 3

Sample Output 1

Kehless

Sample Input 2

1
Jacob 100 1

Sample Output 2

None

Comments

There are no comments at the moment.