#P7480. Reboot from Blue

Reboot from Blue

Description

There are nn gas stations on a number line. The ii-th station is at position xix_i, and its price is cic_i yuan per liter.

At the beginning, YSGH and his car are at position ss, and he wants to go to position tt (s<ts < t). The fuel tank is empty at the start, and it is guaranteed that there is a gas station at position ss.

Assume the car’s fuel tank capacity is unlimited, and 11 liter of fuel can travel a distance of 11.

He wants to know the minimum cost he needs to pay.

Input Format

The first line contains three integers n,s,tn, s, t, with the same meaning as in the statement.

The next nn lines each contain two integers ci,xic_i, x_i, representing the price and position of the ii-th gas station, respectively.

Output Format

Only one line, containing one integer, which is the answer.

3 5 10
10 5
2 4
1 7
19

Hint

Sample Explanation

The optimal plan is to buy 11 liter of fuel at the first gas station to reach the second gas station.

Buy 33 liters at the second gas station to reach the third gas station.

Buy 33 liters at the third gas station to reach the destination.

The answer is 10+2×3+1×3=1910 + 2 \times 3 + 1 \times 3 = 19.


Constraints

This problem uses bundled testdata.

For 100%100\% of the testdata, 1n1051 \le n \le {10}^5, 109xi,s,t109-{10}^9 \le x_i, s, t \le {10}^9, 1ci1091 \le c_i \le {10}^9, s<ts < t, and it is guaranteed that there is a gas station at position ss.

  • Subtask 1 (10 points): n20n \le 20.
  • Subtask 2 (30 points): n5000n \le 5000.
  • Subtask 3 (20 points): cic_i is uniformly random in [1,109][1, {10}^9].
  • Subtask 4 (40 points): No special constraints.

Translated by ChatGPT 5