CF1907D.Jumping Through Segments
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarp is designing a level for a game. The level consists of n segments on the number line, where the i -th segment starts at the point with coordinate li and ends at the point with coordinate ri .
The player starts the level at the point with coordinate 0 . In one move, they can move to any point that is within a distance of no more than k . After their i -th move, the player must land within the i -th segment, that is, at a coordinate x such that li≤x≤ri . This means:
- After the first move, they must be inside the first segment (from l1 to r1 );
- After the second move, they must be inside the second segment (from l2 to r2 );
- ...
- After the n -th move, they must be inside the n -th segment (from ln to rn ).
The level is considered completed if the player reaches the n -th segment, following the rules described above. After some thought, Polycarp realized that it is impossible to complete the level with some values of k .
Polycarp does not want the level to be too easy, so he asks you to determine the minimum integer k with which it is possible to complete the level.
输入格式
The first line contains a single integer t ( 1≤t≤104 )—the number of test cases. Descriptions of the test cases follow.
The first line of each test case contains a single integer n ( 1≤n≤2⋅105 )—the number of segments in the level.
The following n lines.
The i -th line contain two integers li and ri ( 0≤li≤ri≤109 )—the boundaries of the i -th segment. Segments may intersect.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, output a single integer—the minimum value of k with which it is possible to complete the level.
输入输出样例
输入#1
4 5 1 5 3 4 5 6 8 10 0 1 3 0 2 0 1 0 3 3 3 8 10 18 6 11 4 10 20 0 5 15 17 2 2
输出#1
7 0 5 13
说明/提示
In the third example, the player can make the following moves:
- Move from point 0 to point 5 ( 3≤5≤8 );
- Move from point 5 to point 10 ( 10≤10≤18 );
- Move from point 10 to point 7 ( 6≤7≤11 ).
Note that for the last move, the player could have chosen not to move and still complete the level.