Problem list
Log in
#icpc00074 · ICPC World Finals 2017

Need for Speed

Gold V 1.0 s 1024 MB

Sheila is a student and she drives a typical student car: it is old, slow, rusty, and falling apart. Recently, the needle on the speedometer fell off. She glued it back on, but she might have placed it at the wrong angle. Thus, when the speedometer reads $s$, her true speed is $s + c$, where $c$ is an unknown constant (possibly negative). Sheila made a careful record of a recent journey and wants to use this to compute $c$. The journey consisted of $n$ segments. In the $i^{th}$ segment she traveled a distance of $di$ and the speedometer read $si$ for the entire segment. This whole journey took time $t$. Help Sheila by computing $c$. Note that while Sheila’s speedometer might have negative readings, her true speed was greater than zero for each segment of the journey.

Input

The first line of input contains two integers $n$ ($1 \le n \le 1,000$), the number of sections in Sheila’s journey, and $t$ ($1 \le t \le 10^{6}$), the total time. This is followed by $n$ lines, each describing one segment of Sheila’s journey. The $i^{th}$ of these lines contains two integers $d_{i}$ ($1 \le d_{i} \le 1,000$) and $s_{i}$ (|$s_{i}$| ≤1 000), the distance and speedometer reading for the $i^{th}$ segment of the journey. Time is specified in hours, distance in miles, and speed in miles per hour.

Output

Display the constant $c$ in miles per hour. Your answer should have an absolute or relative error of less than $10^{−}^{6}$.

Example 1

Input
3 5
4 -1
4 0
10 3
Output
3.000000000

Example 2

Input
4 10
5 3
2 2
3 6
3 1
Output
-0.508653377
Source
ICPC World Finals 2017
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code