#P9455. [入门赛 #14] 塔台超频 (Hard Version)
[入门赛 #14] 塔台超频 (Hard Version)
Problem Description
There are towers on a straight road. They are numbered in order, and are located at distances from the start of the road ().
Each tower initially has a communication radius . This means that tower can communicate with towers whose positions are within the range .
Note in particular: for two towers A and B, B can transmit a signal to A if and only if A's position is within B's communication range. Note that this is not the same as “their communication ranges overlap, so they can communicate”.
Now you can overclock these towers. Specifically, you may choose a voltage , and then all towers will have their voltage increased by , so their communication radii will each increase by . Here can only be a non-negative integer.
You are required to overclock the towers so that a signal can be transmitted from tower to tower , with no restriction on the path (that is, you only need the signal to reach tower from tower in some way). However, unreasonable overclocking will seriously wear out the towers, so you want to make the overclocking voltage as small as possible.
Compute the minimum voltage needed for overclocking to achieve the goal above.
Input Format
The input has lines.
The first line contains an integer , representing the number of towers.
The next lines each contain two integers , representing the position and the initial communication radius of each tower.
Output Format
Output one line with one integer, representing the minimum voltage needed for overclocking to achieve the goal.
10
2 3
5 0
6 3
7 2
8 0
10 0
13 2
14 4
15 4
18 2
3
Hint
Constraints
For of the testdata, it is guaranteed that , and .
Translated by ChatGPT 5