#P40010. 2019 ICPC NCNA Regional Contest k - Solar Energy

2019 ICPC NCNA Regional Contest k - Solar Energy

题目描述

image.png

You are planning to travel in interstellar space in the hope of finding habitable planets. You have already identified NN stars that can recharge your spaceship via its solar panels. The only work left is to decide the orientation of the spaceship that maximizes the distance it can travel.

Space is modeled as a 2D plane, with the Earth at the origin. The spaceship can be launched from the Earth in a straight line, in any direction. Star ii can provide enough energy to travel TiT_i distance if the spaceship is launched at an angle of aia_i with the xx-axis. If the angle is not perfectly aligned, then the spaceship gets less energy. Specifically, if the launch direction makes an angle of aa with the xx-axis, then it gets enough energy to travel distance of [\max(0, T_i - s_i \cdot \mathrm{dist}(a_i, a))] from star ii, where dist(a,b)\mathrm{dist}(a,b) is the minimum radians needed to go from angle aa to bb. The distance that the spaceship can travel is simply the sum of the distances that each star contributes. Find the maximum distance TT that the starship can travel.

输入格式

The first line contains the value NN, 1N1051\le N\le 10^5. Following this are NN lines each containing three real numbers TiT_i, sis_i, and aia_i, with 0<Ti10000<T_i\le 1\,000, 0si1000\le s_i\le 100, and 0ai<2π0\le a_i < 2\pi. All real numbers in the input have at most 66 digits after the decimal point.

输出格式

On a single line output the maximum distance the spacecraft can travel. Your answer is considered correct if it has an absolute or relative error of at most 10610^{-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