PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000372. Hiệu chỉnh đồng hồ tốc độ (Need for Speed)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hiệu chỉnh đồng hồ tốc độ (Need for Speed)

Need for Speed

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

Sheila's car has a miscalibrated speedometer. A reading of ss corresponds to a true speed of s+cs+c, where the unknown constant cc may be negative.

Her recorded journey consists of nn segments. On segment ii, the car travels did_i miles while the speedometer continuously displays sis_i miles per hour. The entire journey lasts tt hours. A displayed speed may be negative, but the actual speed is strictly positive on every segment.

Determine the speedometer offset cc from the recorded data.

Input

The first line contains two integers n,tn,t, the number of segments and total duration in hours.

Each of the following nn lines contains two integers di,sid_i,s_i, the distance in miles and the displayed speed in miles per hour on segment ii.

Output

Print one real number cc in miles per hour. For submitted value aa and correct value bb, acceptance requires ∣a−b∣<10−6max⁡(1,∣b∣)|a-b|<10^{-6}\max(1,|b|).

Subtasks

  • Subtask 1 (20 points): n=1n=1; 1≤t≤1061\le t\le10^6; 1≤di≤10001\le d_i\le1000, −1000≤si≤1000-1000\le s_i\le1000 (1≤i≤n1\le i\le n).
  • Subtask 2 (30 points): 1≤n≤10001\le n\le1000; 1≤t≤1061\le t\le10^6; 1≤di≤10001\le d_i\le1000, −1000≤si≤1000-1000\le s_i\le1000 (1≤i≤n1\le i\le n); s1=s2=⋯=sns_1=s_2=\cdots=s_n.
  • Subtask 3 (50 points): 1≤n≤10001\le n\le1000; 1≤t≤1061\le t\le10^6; 1≤di≤10001\le d_i\le1000, −1000≤si≤1000-1000\le s_i\le1000 (1≤i≤n1\le i\le n).

Examples

Input

3 5
4 -1
4 0
10 3

Output

3.000000000

Explanation

For c=3c=3, the actual speeds are 2,3,62,3,6. The travel times are 22, 4/34/3, and 5/35/3 hours, summing to 55. All speeds are positive. Since the total time strictly decreases with cc, this is the unique solution.

Input

1 4
8 5

Output

-3.000000000

Explanation

The true speed is 8/4=28/4=2 miles per hour. The reading is 55, so c=2−5=−3c=2-5=-3.

Input

2 3
3 2
6 2

Output

1.000000000

Explanation

Both readings are 22. Total distance is 99 miles in 33 hours, so the true speed is 33 and the offset is 11.

Input

4 10
5 3
2 2
3 6
3 1

Output

-0.508653377

Explanation

For c≈−0.508653377c\approx-0.508653377, the four true speeds are approximately 2.4913466232.491346623, 1.4913466231.491346623, 5.4913466235.491346623 and 0.4913466230.491346623 miles per hour, all positive. Total time $5/2.491346623+2/1.491346623+3/5.491346623+3/0.491346623$ is approximately 10 hours. Total time strictly decreases as cc increases, so this identifies the unique root within the permitted error.