QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100

#4943. 警察局

统计

在 Flatland 有 $N$ 个警察局,第 $i$ 个警察局位于坐标 $(x_i, y_i)$。当局计划通过减少它们之间经常出现的沟通误解来增强这些警察局之间的协同效应。为此,当局决定建造一个新的塔,作为通信控制中心(Communication Control Center, CCC)。注意,CCC 只能建在坐标 $(x, y)$ 处,其中 $x$ 和 $y$ 均为整数。在 $(x, y)$ 处是否已经有警察局并不重要,CCC 可以与该警察局建在一起。

随后,CCC 将向每个警察局铺设一条通信电缆,并受到一些限制:

  • 每条电缆仅服务于一个警察局,因此,要服务 $N$ 个警察局,需要 $N$ 条电缆。
  • 电缆只能平行于 $x$ 轴和 $y$ 轴铺设;不允许对角线交叉。

由于 Flatland 中一些奇怪的物理定律,每条电缆在 $x$ 轴方向上的长度最多为 $L$,在 $y$ 轴方向上的长度最多为 $W$;这就是这种类型的电缆在 Flatland 中被称为 $\langle L, W \rangle$ 电缆的原因。为了保持稳定的通信,所有警察局都应使用相同类型的电缆连接。

Flatland 最近的科技进步使得物理学家可以以一定的成本制造出任意 $L$ 和 $W$ 的 $\langle L, W \rangle$ 电缆。由于 $L$ 和 $W$ 越大,成本就越昂贵,当局需要找出能满足其需求的 $L$ 和 $W$,即在连接所有警察局到 CCC 的同时,最小化 $L + W$ 的值。

你的任务是找到 $L$ 和 $W$,使得 $L + W$ 的值最小,并且当局可以在坐标 $(x, y)$($x$ 和 $y$ 均为整数)处建造 CCC,同时所有警察局都可以通过 $\langle L, W \rangle$ 电缆连接到 CCC。如果有多个解,优先最小化 $L$,然后再最小化 $W$。

输入格式

输入的第一行包含一个整数 $N$ ($1 \le N \le 100\,000$),表示 Flatland 中警察局的数量。接下来的 $N$ 行,每行包含两个整数 $x_i, y_i$ ($-10^6 \le x_i, y_i \le 10^6$),表示每个警察局的位置。

输出格式

输出一行,包含两个整数(用单个空格分隔),分别为 $L$ 和 $W$,使得 $L + W$ 的值最小,且当局可以在坐标 $(x, y)$($x$ 和 $y$ 均为整数)处建造 CCC,同时所有警察局都可以通过 $\langle L, W \rangle$ 电缆连接到 CCC。如果有多个解,优先最小化 $L$,然后再最小化 $W$。

样例

样例输入 1

5
20 90
-10 40
90 20
50 -30
50 70

样例输出 1

50 60

说明 1

当局可以做出的最优决定是在 $(40, 30)$ 处建造 CCC,并准备 $\langle 50, 60 \rangle$ 电缆将所有警察局连接到 CCC。

样例输入 2

2
120 740
122 749

样例输出 2

1 5

说明 2

为了使 $L + W$ 最小,CCC 必须建在 $(121, 744)$ 或 $(121, 745)$。无论哪种方式,他们都需要 $\langle 1, 5 \rangle$ 电缆来将两个警察局连接到 CCC。

样例输入 3

5
-30 -7
2 80
23 15
31 30
92 -20

样例输出 3

61 50

说明 3

当局可以做出的最优决定是在 $(31, 30)$ 处建造 CCC,并准备 $\langle 61, 50 \rangle$ 电缆将所有警察局连接到 CCC。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.