Thread Knots
题号:NC221644
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

There are n threads on the x-axis. The length of the i-th thread, say T_i, is denoted by l_i and the location of its starting point by x_i, both being integers. We want to make a knot in each thread. The location of the knot must also be an integer. The knot can be made at any point in the thread and it is assumed that the length of the thread is not reduced by the knot. You can assume that no thread is totally contained by another, which means that there are no two threads T_i and such that and .

We want to determine the location of the knot for each thread in order to make the distance between the closest two neighboring knots as big as possible.

For example, the figures below show the locations of the knots for six threads. The location of a knot is denoted by a point. All the threads actually lie on the x-axis, however, they are drawn separately to distinguish each other. In Figure I.1, the distance between the closest two knots is 20. However, if we make the knot for T_2 at different location as shown in Figure I.2, the distance between the closest two knots becomes 25, which is what this problem requests.

Given information about the n threads, write a program that calculates the maximum distance between two closest knots.

输入描述:

Your program is to read from standard input. The input starts with a line containing one integer, , where n is the number of threads. In the following n lines, the i-th line contains two integers  and ݈, where x_i and ݈l_i denote the location of the starting point and the length of the i-th thread, respectively. You can assume that no thread is totally contained by another, which means that there  are no two threads T_i and  such that  and 

输出描述:

Your program is to write to standard output. Print exactly one line. The line should contain an integer which is the maximum distance between two closest knots. 

The following shows sample input and output for three test case.
示例1

输入

复制
6
0 67
127 36
110 23
50 51
100 12
158 17

输出

复制
25
示例2

输入

复制
6
0 40
10 55
45 28
90 40
83 30
120 30

输出

复制
30
示例3

输入

复制
3
0 20
40 10
100 20

输出

复制
50