QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#3912. 王国划分

统计

最近,Bandiaterra 的国王 Barbato 开始考虑如何将他的王国分给两个儿子 Philip 和 Ferdinand。Barbato 的领地可以用 $N$ 座城堡来表示,这些城堡可以表示为整点坐标 $(X_i, Y_i)$。由于国王同样爱他的两个儿子,他决定根据 Bandiaterra 公平准则进行划分。

为了进行划分,需要画一条平行于 Y 轴的直线。这条直线经过点 $(X, 0)$。位于边界线以西($X_i \le X$)的城堡将由 Philip 继承,位于边界线以东($X < X_i$)的城堡将由 Ferdinand 继承。最终,每个兄弟都将拥有一座城市,该城市可以分别表示为 Philip 和 Ferdinand 所继承城堡的凸包。根据 Bandiaterra 公平准则,如果 Philip 和 Ferdinand 的城市面积之差的绝对值越接近 Bandiaterra 的神圣数字 $S$,则划分越公平。

Barbato 召集了 Bandiaterra 的长老会议,以决定边界线的确切位置并将其记录在遗嘱中。

输入格式

第一行包含两个整数 $N$ 和 $S$,分别表示城堡的数量和神圣数字。 接下来 $N$ 行,每行包含两个整数 $X_i$ 和 $Y_i$,表示每座城堡的坐标。没有两座城堡位于同一坐标。没有城堡的空城市面积为零。

$1 \le N \le 100\,000$ $0 \le S \le 1\,000\,000\,000$ $|X_i|, |Y_i| \le 10\,000$

输出格式

输出一行一个数字,表示城市面积之差的绝对值,该值应尽可能接近 Bandiaterra 的神圣数字。如果存在多个可能的边界线,输出使得城市面积之差的绝对值最小的那一个。你的答案的绝对误差和相对误差不应超过 $10^{-4}$。

样例

样例输入 1

9 31
8 5
-3 1
1 -1
-4 -3
-2 -9
3 -4
9 0
1 7
-7 2

样例输出 1

42.0000

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.