QOJ.ac

QOJ

時間限制: 5 s 記憶體限制: 2048 MB 總分: 100

#5727. 星际旅行

统计

你计划在星际空间中旅行,希望能找到宜居行星。你已经确定了 $N$ 颗可以通过太阳能电池板为你的飞船充电的恒星。剩下的唯一工作就是确定飞船的朝向,以使它能行驶的距离最大化。

空间被建模为一个二维平面,地球位于原点。飞船可以从地球出发,沿直线向任意方向发射。如果飞船以与 $x$ 轴成 $a_i$ 角的方向发射,第 $i$ 颗恒星可以提供足够的能量让飞船行驶 $T_i$ 的距离。如果角度没有完全对准,飞船获得的能量就会减少。具体来说,如果发射方向与 $x$ 轴的夹角为 $a$,那么它从第 $i$ 颗恒星获得的能量足以行驶的距离为:

$$\max(0, T_i - s_i \cdot \text{dist}(a_i, a))$$

其中 $\text{dist}(a, b)$ 是从角度 $a$ 到 $b$ 所需的最小弧度。飞船可以行驶的总距离即为每颗恒星贡献的距离之和。请找出飞船可以行驶的最大距离 $T$。

输入格式

第一行包含一个整数 $N$,$1 \le N \le 10^5$。接下来有 $N$ 行,每行包含三个实数 $T_i$、$s_i$ 和 $a_i$,其中 $0 < T_i \le 1000$,$0 \le s_i \le 100$,且 $0 \le a_i < 2\pi$。输入中的所有实数小数点后最多有 6 位。

输出格式

在一行中输出飞船可以行驶的最大距离。如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则被视为正确。

样例

样例输入 1

2
100 1 1
100 1 1.5

样例输出 1

199.500000

样例输入 2

4
100 1 0.5
200 1 1
100 0.5 1.5
10 2 3

样例输出 2

405.500000

飞船示意图

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.