QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 256 MB Puntuación total: 100

#18176. 飞行的门

Estadísticas

Artem 和 Kostya 正在玩一个游戏。Artem 有 $n$ 扇带有可移动顶棚的门。门的地板固定在高度 $0$ 处,顶棚的高度可以改变。每扇门有两个参数 $a_i, b_i$:$a_i$ 是顶棚的初始高度,$b_i$ 是顶棚移动的速度。如果 $b_i > 0$,则顶棚以每秒 $b_i$ 米的速度向上移动。如果 $b_i < 0$,则顶棚以每秒 $-b_i$ 米的速度向下移动,直到高度降为 $0$ 并停止。如果 $b_i = 0$,则顶棚始终固定在高度 $a_i$。

游戏过程如下:Artem 将这 $n$ 扇门以某种顺序放置在 $Ox$ 轴上坐标为 $1, 2, \dots, n$ 的点上。游戏开始前,Kostya 位于点 $x = 0$ 处。他选择某个高度 $h \ge 0$ 和速度 $v > 0$(这里我们将 Kostya 视为一个质点)。随后 Artem 鸣枪开赛,门的顶棚开始移动,同时 Kostya 以恒定的高度 $h$ 和恒定的速度 $v$ 沿 $Ox$ 轴正方向开始他的旅程。Kostya 必须穿过所有的门。因此,如果 Kostya 飞过某个坐标 $i$ 时,该坐标处门的顶棚严格低于 Kostya(即顶棚高度小于 $h$),则 Kostya 输掉游戏。

为了让游戏更有趣,Kostya 决定采用随机化策略。他在实数区间 $[0, 10^9]$ 内均匀随机地选择高度 $h$。然后,如果存在能让他获胜的速度,他会选择某个能让他获胜的速度 $v > 0$。对于门的每一种排列方式,考虑 Kostya 在使用该策略时获胜的概率。Artem 希望以某种顺序排列这些门,使得该获胜概率最小。帮助 Artem 找到这个最小概率。为了方便输出,请输出该概率乘以 $10^9$ 后的值。

输入格式

输入的第一行包含一个正整数 $n$($1 \le n \le 5 \cdot 10^5$),表示 Artem 拥有的门的数量。

接下来的 $n$ 行,每行包含两个整数 $a_i, b_i$($1 \le a_i \le 10^9$,$|b_i| \le 10^9$),表示第 $i$ 扇门的初始高度和顶棚移动速度。

输出格式

在唯一的一行中输出一个实数,表示 Kostya 获胜的最小概率乘以 $10^9$ 后的值。

如果绝对误差或相对误差小于 $10^{-6}$,则认为答案正确。请注意,此误差规则适用于输出的值(即乘以 $10^9$ 后的值),而不是原始的概率值。

样例

输入样例 1

3
1 2
3 -2
2 1

输出样例 1

1.5000000000

输入样例 2

1
1 2

输出样例 2

1000000000.0000000000

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.