atcoder#ARC069D. [ARC069F] Flags

[ARC069F] Flags

Score : 12001200 points

Problem Statement

Snuke loves flags.

Snuke is placing NN flags on a line.

The ii-th flag can be placed at either coordinate xix_i or coordinate yiy_i.

Snuke thinks that the flags look nicer when the smallest distance between two of them, dd, is larger. Find the maximum possible value of dd.

Constraints

  • 2N1042 \leq N \leq 10^{4}
  • 1xi,yi1091 \leq x_i, y_i \leq 10^{9}
  • xix_i and yiy_i are integers.

Input

The input is given from Standard Input in the following format:

NN

x1x_1 y1y_1

::

xNx_N yNy_N

Output

Print the answer.

3
1 3
2 5
1 9
4

The optimal solution is to place the first flag at coordinate 11, the second flag at coordinate 55 and the third flag at coordinate 99. The smallest distance between two of the flags is 44 in this case.

5
2 2
2 2
2 2
2 2
2 2
0

There can be more than one flag at the same position.

22
93 6440
78 6647
862 11
8306 9689
798 99
801 521
188 206
6079 971
4559 209
50 94
92 6270
5403 560
803 83
1855 99
42 504
75 484
629 11
92 122
3359 37
28 16
648 14
11 269
17