Positioning the Legend
Pike Street Studio is charting two lines that converge, and the automatic key placement keeps landing the key exactly where they meet. Left to itself the placement looks for the emptiest corner, and the emptiest corner is often the most interesting one. Pinning the key to a fixed corner is the fix. Since the meeting point is the reason the chart exists, the studio also prints where it happens.
Task: Print the label of the point at which the two lines come closest together, measuring closeness as the gap between the two values regardless of which line is on top. If two or more points are equally close, print the label of whichever appears earliest in the list.
Input
The first line holds an integer n, the number of points. Each of the next n lines holds three fields separated by single spaces: the point's label as a whole number, then line A's value there, then line B's. n is at least 1.
Output
One line holding the point's label as a whole number.
Example:
Input:
3
1 10 12
2 20 20
3 30 25
Output:
2
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