A Horizontal Box Plot
Ironbark Manufacturing charts machines whose names are long enough that upright boxes end up with unreadable labels, so the chart is turned on its side: names down the left, boxes running right. The maintenance list wants the machine whose measurements are most spread out from end to end, since that is the one whose behaviour is least predictable.
Task: Print the machine with the widest spread of measurements.
Input
The first line holds one integer n, the number of measurements. Each of the next n lines holds a machine name and one measurement, separated by a single space. Machine names contain no spaces, and a machine may appear on many lines.
Output
One line holding a single machine name, exactly as it was read. A machine's spread is its largest measurement less its smallest, so a machine with only one measurement has a spread of zero. If two machines tie, print whichever name comes first alphabetically.
Example:
Input:
4
A 10
A 20
B 5
B 100
Output:
B
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