#P1661. 扩散

扩散

Description

Each point expands by a distance of 1 in the four cardinal directions every unit of time, as shown in the figure.

Two points aa and bb are connected, denoted e(a,b)e(a,b), if and only if the expansion regions of aa and bb have a nonempty intersection. A connected component is defined so that for any two points uu and vv within the component, there exists a path e(u,a0),e(a0,a1),,e(ak,v)e(u,a_0), e(a_0,a_1), \cdots, e(a_k,v). Given nn points on the plane, find the earliest time when they form a single connected component.

Input Format

The first line contains an integer nn. Each of the next nn lines contains two integers XiX_i and YiY_i, the coordinates of a point.

Output Format

Output a single number, representing the earliest time when all points form a single connected component.

2
0 0
5 5
5

Hint

Constraints

  • For 20%20\% of the testdata, 1n51 \le n \le 5, 1Xi,Yi501 \le X_i, Y_i \le 50.
  • For 100%100\% of the testdata, 1n501 \le n \le 50, 1Xi,Yi1091 \le X_i, Y_i \le 10^9.

Translated by ChatGPT 5