atcoder#ARC121A. [ARC121A] 2nd Greatest Distance

[ARC121A] 2nd Greatest Distance

Score : 400400 points

Problem Statement

There are NN houses numbered 11 through NN on a two-dimensional plane. House ii is at (xi,yi)(x_i, y_i).

We use Chebyshev distance to calculate the distance between two houses. That is, the distance between Houses ii and jj is max(xixj,yiyj)\max(|x_i - x_j|, |y_i-y_j|).

There are N(N1)2\frac{N(N-1)}{2} pairs formed by two different houses. For each of these pairs, we will calculate the distance between the houses, and then we will sort these distances in descending order to get a sequence of length N(N1)2\frac{N(N-1)}{2}. Find the second value from the beginning of this sequence.

Constraints

  • All values in input are integers.
  • 3N2×1053 \leq N \leq 2 \times 10^{5}
  • 109xi,yi109-10^{9} \leq x_i, y_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

NN

x1x_{1} y1y_{1}

\vdots

xNx_{N} yNy_{N}

Output

Print the second value from the beginning of the sequence of distances of different houses sorted in descending order.

3
0 0
1 2
4 0
3
  • The distance between Houses 11 and 22 is 22;
  • The distance between Houses 11 and 33 is 44;
  • The distance between Houses 22 and 33 is 33.
  • By sorting these in descending order, we get (4,3,2)(4,3,2), where the second value from the beginning is 33.
4
0 0
0 0
1 0
0 1
1
  • There may be multiple houses at the same coordinates.
20
407 361
167 433
756 388
-551 -47
306 -471
36 928
338 -355
911 852
288 70
-961 -769
-668 -386
-690 -378
182 -609
-677 401
-458 -112
184 -131
-243 888
-163 471
-11 997
119 544
1766