Categorical Plots on a Numeric Axis With native_scale
The Ravensworth Group plots a figure per year, and the years are not evenly spaced -- there are gaps where nothing was recorded. Treated as plain labels they would be drawn at equal distances, which flattens a twenty-year gap into the same step as a one-year gap; drawn on a real number line the spacing tells the truth. The commentary quotes the figure from the middle of the period covered.
Task: Print the value for the year closest to the midpoint of the year range.
Input
The first line holds one integer n, the number of records, where 1 <= n <= 1000. Then come n lines, each holding a year and a value separated by a single space.
Output
One line holding that year's value, rounded to 2 decimal places. The midpoint is halfway between the earliest and the latest year, and need not be a year that exists. If two years are equally close to it, use the one that appears earlier in the input.
Example:
Input:
3
2000 10
2010 20
2020 30
Output:
20.00
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