logo AlgoBeat OnlineJudge
登录 注册

#212606. [UOI 2025] Manhattan Pairing

内存限制:256 MiB 时间限制:2500 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

For a pair of points on the Cartesian plane and , we define the Manhattan distance between them as . For example, for the pair of points and , the Manhattan distance between them is .

You are given points on the Cartesian plane, whose coordinates are integers. All -coordinates of the given points are either or .

Split the given points into pairs such that each of these points belongs to exactly one pair, and the maximum Manhattan distance between the points of one pair is minimized.

输入格式

The first line contains a single integer .

In the following lines, each line contains two integers and --- the coordinates of the corresponding point.

输出格式

Output a single integer --- the maximum Manhattan distance between the points of one pair in the optimal partition.

样例

样例输入 1

1
3 1
1 0

样例输出 1

3

样例输入 2

3
18 0
3 0
1 0
10 0
8 0
14 0

样例输出 2

4

样例输入 3

4
3 0
0 1
5 0
2 1
6 0
3 0
5 1
2 1

样例输出 3

2

数据范围与提示

In the second example, the pairing , , and is the only optimal partition. The Manhattan distances between the points of one pair in this partition are , , and , respectively.

In the third example, the pairing , , , and is an optimal partition. All Manhattan distances between the points of one pair in this partition are equal to .

Illustration for the third example

Scoring

  • ( points): ;
  • ( points): for ;
  • ( points): ;
  • ( points): ;
  • ( points): for ;
  • ( points): for ;
  • ( points): ;
  • ( points): no additional restrictions.