#P9181. [COCI 2022/2023 #5] Zastave
[COCI 2022/2023 #5] Zastave
Problem Description
There are right triangles. The -th right triangle has hypotenuse length . The sum of the heights of these right triangles does not exceed . Find the maximum possible total area of these right triangles.
Input Format
The first line contains two integers , representing the number of triangles and the maximum allowed sum of their heights.
The second line contains integers .
Output Format
Output the maximum possible total area of these right triangles (keep digits after the decimal point). Your output is considered correct if its absolute error or relative error is at most compared to the answer.
2 3
4 5
6.5200982141
1 6
10
24.0000000000
4 7
5 5 6 6
18.5706715170
Hint
Explanation for sample :
The maximum possible case is a triangle with side lengths , with area .
| Subtask ID | Additional Constraints | Score |
|---|---|---|
| Sample only | ||
| No additional constraints |
Translated by ChatGPT 5