#abc215f. F - Dist Max 2

F - Dist Max 2

Score : 500500 points

问题描述

给定二维平面上 NN 个不相同的点。第 ii 个点 (1iN)(1 \leq i \leq N) 的坐标为 (xi,yi)(x_i, y_i)

我们定义两点 iijj 之间的距离为 min(xixj,yiyj)\mathrm{min} (|x_i-x_j|, |y_i-y_j|):即它们在 xx 坐标上的差值和在 yy 坐标上的差值的较小者。

求出两个不同点之间的最大距离。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given are NN distinct points in a two-dimensional plane. Point ii (1iN)(1 \leq i \leq N) has the coordinates (xi,yi)(x_i,y_i).

Let us define the distance between two points ii and jj be min(xixj,yiyj)\mathrm{min} (|x_i-x_j|,|y_i-y_j|): the smaller of the difference in the xx-coordinates and the difference in the yy-coordinates.

Find the maximum distance between two different points.

Constraints

  • 2N2000002 \leq N \leq 200000
  • 0xi,yi1090 \leq x_i,y_i \leq 10^9
  • (xi,yi)(x_i,y_i) \neq (xj,yj)(x_j,y_j) (ij)(i \neq j)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

x1x_1 y1y_1

x2x_2 y2y_2

\vdots

xNx_N yNy_N

Output

Print the maximum distance between two different points.

Sample Input 1

3
0 3
3 1
4 10

Sample Output 1

4

The distances between Points 11 and 22, between Points 11 and 33, and between Points 22 and 33 are 22, 44, and 11, respectively, so your output should be 44.

Sample Input 2

4
0 1
0 4
0 10
0 6

Sample Output 2

0

Sample Input 3

8
897 729
802 969
765 184
992 887
1 104
521 641
220 909
380 378

Sample Output 3

801

update @ 2024/3/10 09:33:19