All problems

Overlaying Actual Points on a Trend Line

mediumPythonMatplotlibCombined Charts

Kestrel Freight is asked every quarter whether fuel cost is rising "steadily". The chart answers by drawing a straight reference line between the first and last readings and dropping the actual readings on top of it, so any bulge away from that line is visible. The number that goes in the commentary is the size of the biggest bulge.

Task: Print how far the worst reading sits from the straight reference line.

Input

The first line holds one integer n, the number of readings. Each of the next n lines holds a position and that position's reading, separated by a single space. Positions are in increasing order.

Output

One line with exactly one decimal place: the largest distance between a reading and the straight line joining the first reading to the last. Distance is measured straight up or down, and is never negative — a reading below the line counts the same as one above. Print 0.0 when every reading sits on the line.

Example:

Input:
3
1 10
2 25
3 30

Output:
5.0

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…