question archive Joey loves to eat Pizza
Subject:Computer SciencePrice:2.89 Bought3
Joey loves to eat Pizza. But he is worried as the quality of pizza made by most of the restaurants is deteriorating. The last few pizzas ordered by him did not taste good :(. Joey is feeling extremely hungry and wants to eat pizza. But he is confused about the restaurant from where he should order. As always he asks Chandler for help.
Chandler suggests that Joey should give each restaurant some points, and then choose the restaurant having maximum points. If more than one restaurant has same points, Joey can choose the one with lexicographically smallest name.
Joey has assigned points to all the restaurants, but can't figure out which restaurant satisfies Chandler's criteria. Can you help him out?
Input:
First line has N, the total number of restaurants.
Next N lines contain Name of Restaurant and Points awarded by Joey, separated by a space. Restaurant name has no spaces, all lowercase letters and will not be more than 20 characters.
Output:
Print the name of the restaurant that Joey should choose.
Constraints:
1 <= N <= 105
1 <= Points <= 106
SAMPLE INPUT 3 Pizzeria 108 Dominos 145 Pizzapizza 49
SAMPLE OUTPUT Dominos
Explanation Dominos has maximum points.
Note: Use Java 7 programming lang..
Purchased 3 times