#P4322. [JSOI2016] 最佳团体
[JSOI2016] 最佳团体
Description
There are candidates in the JSOI informatics team, numbered from to . For convenience, JYY is numbered . Each candidate is recommended by a candidate with a smaller number . If , it means this candidate was picked by JYY himself.
To ensure team harmony, JYY requires that if candidate is recruited, then candidate must also be in the team. JYY is always in the team. Each candidate has a combat power and a recruitment cost . JYY wants to recruit candidates (excluding JYY) to form the team with the best ratio; that is, maximize the ratio of the total combat power to the total recruitment cost of these selected candidates.
Input Format
The first line contains two positive integers and .
The -th of the next lines contains three integers , , , indicating candidate ’s recruitment cost, combat power, and recommender number.
Output Format
Print one real number, the best ratio. The answer should be rounded to three decimal places.
1 2
1000 1 0
1 1000 1
0.001
Hint
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号