#C9763. Highest Selling Product

    ID: 53892 Type: Default 1000ms 256MiB

Highest Selling Product

Highest Selling Product

You are given a list of sales records. Each record consists of a product name and an integer representing its sales amount. Your task is to determine the product with the highest total sales. In other words, if there are n records and each record is given by ( (p_i, s_i) ) where ( p_i ) is the product name and ( s_i ) is its sales amount, you need to compute the product ( p ) such that [ Total(p)=\sum_{i:,p_i=p} s_i ] is maximized. In the event of a tie, return the product that appears first in the input.

The problem requires you to read the input from standard input and print the result to standard output.

inputFormat

The first line contains an integer ( n ) representing the number of sales records. Each of the following ( n ) lines contains a product name (a string without spaces) and an integer representing the sales amount, separated by a space.

outputFormat

Print a single line containing the name of the product with the highest total sales. In case of a tie, output the product that appears first in the input.## sample

1
Apple 50
Apple