QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100

#1880. 尼卡诺尔喜欢游戏

الإحصائيات

Nikanor 把他所有的空闲时间都花在了游戏上。正因如此,他在大学里的成绩很差,但这又是另一个故事了。他还喜欢赌博。在这个问题中,我们考虑一种名为“Orlyanka”的游戏的变体。游戏有两名玩家,每人都有自己的硬币。硬币的两个面上各有一个整数。玩家掷硬币,数字较大者获胜。我们可以假设每枚硬币两面朝上的概率相等。

今晚,Nikanor 要和他的朋友们玩这个游戏。Nikanor 有 $n$ 个朋友,他将与每位朋友进行一场赌注为 $x_i$ 卢布的游戏。幸运的是,Nikanor 知道他的第 $i$ 位朋友的硬币上写着数字 $a_i$ 和 $b_i$。如果 Nikanor 赢了,他将获得 $x_i$ 卢布。否则,他将支付给朋友 $x_i$ 卢布。如果 Nikanor 和他的朋友掷出的数值相同,则 Nikanor 被判定为获胜。

现在,Nikanor 打算去商店买一枚硬币用于所有的游戏,以使他的期望利润最大化(需扣除硬币成本)。在商店里,一枚数字为 $a$ 和 $b$ 的硬币售价为 $a \cdot b$ 卢布。Nikanor 可以购买任何带有正整数的硬币。

Nikanor 很难做出正确的决定……他请求你帮他选择一枚硬币,使得期望利润尽可能高。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 2 \cdot 10^5$),表示朋友的数量。

接下来的 $n$ 行,每行包含三个整数 $a_i, b_i$ 和 $x_i$ ($1 \le a_i, b_i, x_i \le 10^9$),分别表示第 $i$ 位朋友硬币上的数字以及第 $i$ 场游戏的赌注(单位为卢布)。

输出格式

输出一个实数,表示最大期望利润。

如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则视为正确。即如果你的答案为 $a$,标准答案为 $b$,当且仅当 $\frac{|a-b|}{\max(1,|b|)} \le 10^{-6}$ 时,你的答案将被接受。

样例

样例输入 1

2
1 4 15
3 5 10

样例输出 1

2.5000000000

样例输入 2

1
2 2 8

样例输出 2

4.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.