QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 1024 MB Puntuación total: 100

#12191. 落基山脉

Estadísticas

落基山脉缆车公司(RMC)计划从落基山脉的最高峰向山脉中较低的点铺设缆车,以便利用缆车将游客运送到最高峰。缆车必须从某个潜在的站点以直线连接到最高峰,且缆车不能穿过山脉的任何部分。不过,缆车可以与山坡重合。

为了服务尽可能多的游客,我们需要将缆车从最高峰连接到尽可能低的站点。请帮助公司确定最高峰左侧和右侧的最佳站点。如果存在多个符合条件的站点,则在左侧选择最左边的站点,在右侧选择最右边的站点。

山脉由 $N$ 个站点 $(x_i, y_i)$ 指定。其中一个是唯一的最高峰 $(x_p, y_p)$,满足 $1 < p < N$ 且对于所有 $i \neq p$ 都有 $y_p > y_i$。注意,最高峰不能是第一个或最后一个站点。整个山脉由连接 $(x_i, y_i)$ 到 $(x_{i+1}, y_{i+1})$ 的直线段描述,其中 $1 \le i < N$ 且 $x_i < x_{i+1}$。

输入格式

输入的第一行包含整数 $N$ ($3 \le N \le 5 \cdot 10^5$),表示站点的数量。接下来的 $N$ 行,每行包含两个整数 $x_i$ 和 $y_i$,指定了 $N$ 个站点。坐标满足 $0 \le x_i, y_i \le 10^9$。保证存在唯一的最高峰,且对于所有 $1 \le i < N$ 满足 $x_i < x_{i+1}$。

输出格式

第一行输出最高峰左侧最佳站点的坐标。第二行输出最高峰右侧最佳站点的坐标。

样例

样例输入 1

5
10 10
20 20
30 40
40 30
50 0

样例输出 1

10 10
40 30

样例输入 2

5
10 10
20 20
30 30
40 20
50 10

样例输出 2

10 10
50 10

样例输入 3

10
10 10
20 35
30 20
40 40
50 45
60 40
70 30
80 40
90 20
1000 10

样例输出 3

20 35
1000 10

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.