题目描述
Problem Description
UT University has a club introduction event called the Row of Tents. There is a road of length $ L $, and umg-kun starts walking from position $ 0 $ to position $ L $ in one direction. umg-kun has a parameter called spirit, and its initial value is $ T $. Here, $ T $ is an integer. For every distance $ 1 $ walked, if the spirit is less than $ T $, it recovers by $ 1 $. If the spirit is $ T $, it does not recover.
There are $ N $ tents on the road, and the $ i $-th tent is located at position $ X_i $. When umg-kun reaches the $ i $-th tent, he is recruited by the club, and his spirit decreases by $ A_i $. If his spirit becomes less than $ 0 $ at this point, umg-kun will collapse on the spot.
Find the minimum initial value of spirit $ T $ needed for umg-kun to reach position $ L $ without collapsing along the way.
Input Format
The input is given from the standard input in the following format:
$ N $ $ L $ $ X_1 $ $ A_1 $ $ X_2 $ $ A_2 $ $\vdots$ $ X_N $ $ A_N $
Output Format
Output the answer in one line.
Sample Input and Output
Sample Input #1
2 7
1 5
4 4
Sample Output #1
6
Sample Input #2
8 11
2 6
3 10
4 8
5 7
7 7
8 1
9 9
10 2
Sample Output #2
42
Notes/Hints
Constraints
- All inputs are integers.
- $1 \leq N \leq 2 \times 10^5$
- $N < L \leq 10^9$
- $0 < X_1 < X_2 < \cdots < X_N < L$
- $1 \leq A_i \leq 10^9 \ (1 \leq i \leq N)$
Sample Explanation 1
If the initial spirit value $ T = 6 $, the spirit changes as follows:
- Upon reaching the first tent, the spirit decreases by $ 5 $, becoming $ 1 $.
- By the time reaching the second tent, the spirit recovers $ 3 $ times, becoming $ 4 $.
- Upon reaching the second tent, the spirit decreases by $ 4 $, becoming $ 0 $.
- By the time reaching position $ 7 $, the spirit recovers $ 3 $ times, ending the event with a spirit of $ 3 $.
If the initial spirit value $ T = 5 $, the spirit would become less than $ 0 $ at the second tent, so the answer is $ 6 $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分