#2396. 曼哈顿配对
曼哈顿配对
Manhattan Pairing
Background
Dawei is studying planar geometry and found that when the y-coordinates of points are highly restricted, the pairing problem becomes very interesting. He gathered some points and asked Congcong to help solve a problem about minimizing the maximum Manhattan distance in a pairing.
Problem Description
For a pair of points and on the Cartesian plane, we define the Manhattan distance between them as . For example, the Manhattan distance between points and is .
Given points on the Cartesian plane with integer coordinates. The -coordinates of all points are either or .
You need to divide these points into pairs such that each point belongs to exactly one pair, and the maximum Manhattan distance among all pairs is minimized.
Input Format
The input is provided from standard input in the following format:
...
The first line contains an integer ().
Each of the next lines contains two integers and (), representing the coordinates of the points.
Output Format
The output should be sent to standard output in the following format:
Output a single integer representing the minimum possible value of the maximum Manhattan distance in an optimal pairing.
Sample
1
3 1
1 0
3
3
18 0
3 0
1 0
10 0
8 0
14 0
4
Sample Explanation
In the second sample, the optimal pairing is , , and . This is the unique optimal pairing. The Manhattan distances are , , and respectively.
4
3 0
0 1
5 0
2 1
6 0
3 0
5 1
2 1
2
Sample Explanation
In the third sample, the optimal pairing is , , , and . The Manhattan distance for each pair is .

Constraints
| Subtask | Score | Additional Constraints |
|---|---|---|
| (for ) | ||
| (for ) | ||
| $x_i \ | ||
| eq x_j$ (for ) | ||
| No additional constraints | ||