#P4915. Expected Knowledge from Magical Books

    ID: 18156 Type: Default 1000ms 256MiB

Expected Knowledge from Magical Books

Expected Knowledge from Magical Books

In this problem, you are given n magical books. Each book has a level ai and a knowledge value wi. A creature can extract the knowledge from a book only if its level is at least as high as the book's level. In other words, if the creature has level b, then the knowledge it can obtain from the books is given by:

K(b)=i:aibwi.K(b)=\sum_{i\,:\,a_i\le b}w_i.

Unfortunately, the creature does not know its exact level. Instead, it only knows that its level is uniformly distributed over an integer range \([L, R]\). Your task is to compute the expected knowledge the creature can obtain, which mathematically is:

E[K]=1RL+1b=LRK(b).E[K]=\frac{1}{R-L+1}\sum_{b=L}^{R}K(b).

Note: The number of books n can be up to 105 and the levels and knowledge values can be as large as 109. Efficient processing and handling of large numbers and ranges is required.

inputFormat

The input begins with an integer n (1 ≤ n ≤ 105), which is the number of magical books.

Each of the next n lines contains two space-separated integers ai and wi (1 ≤ ai, wi ≤ 109), representing the level and the knowledge value of the i-th book.

The final line contains two space-separated integers L and R (1 ≤ L ≤ R ≤ 109), indicating that the creature's level is uniformly distributed among the integers in the inclusive range \([L, R]\).

outputFormat

Output a single number — the expected knowledge the creature can obtain from the magical books. The answer is accepted if its absolute or relative error does not exceed 10-6.

sample

3
3 10
5 20
7 30
3 7
40.000000

</p>