QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#10976. 守卫计划

统计

在二维坐标平面上有 $N$ 名保安。第 $i$ 名保安站在点 $(x_i, y_i)$ 处。

你可以执行任意次数(包括零次)以下操作: 选择两个当前有保安站立的点,并在连接这两个点的线段上选择任意一点。如果该点处还没有保安,则在该点放置一名新保安。

站在点 $(a, b)$ 处的保安会监视所有位于 $x$ 坐标小于等于 $a$ 且 $y$ 坐标小于等于 $b$ 的区域内的保安。 没有被任何其他保安监视的保安被称为“必要保安”。

请确定最终配置下必要保安的最小数量,以及达到该配置所需的最少操作次数。

输入格式

输入按以下格式给出:

$N$ $x_1 \ y_1$ $x_2 \ y_2$ $\vdots$ $x_N \ y_N$

  • 所有输入值均为整数。
  • $1 \le N \le 2 \times 10^5$
  • $0 \le x_i, y_i \le 10^9$
  • $(x_i, y_i) \neq (x_j, y_j) \ (i \neq j)$

输出格式

第一行输出一个整数,表示必要保安的最小数量。 第二行输出一个整数,表示达到该配置所需的最少操作次数。

样例

样例输入 1

5
1 6
2 4
3 3
4 2
6 1

样例输出 1

4
1

样例输入 2

3
0 0
1 2
2 1

样例输出 2

2
0

样例输入 3

7
10 49
9 27
59 8
19 22
0 50
25 23
33 13

样例输出 3

4
1

说明

在第一个样例中,选择位于点 $(1, 6)$ 和 $(6, 1)$ 之间线段上的点 $(3, 4)$,并在该处放置一名新保安。操作完成后,必要保安将是位于 $(1, 6)$、$(3, 4)$、$(4, 2)$ 和 $(6, 1)$ 处的四名保安。

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.