Charting Units Sold by Product
The weekly trading pack at Alderwood Supply opens with a bar chart of units sold per product, and directly under it a single line naming the product that led the week. The buyer reads that line first and only studies the chart when the line surprises her. The starter code already draws the chart; nothing about the picture is checked, and what you have to produce is that line. If two products sold exactly the same number and share the lead, the one listed first in the file is the one named.
Task: Print the name of the product that sold the most units.
Input
The first line holds an integer n, the number of products. Each of the next n lines holds a product name and its units sold, separated by a single space. A name contains no spaces.
Output
One line holding the leading product's name, spelled exactly as it appears in the input.
Example:
Input:
3
Desk 40
Chair 90
Lamp 60
Output:
Chair
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