P29936 [洛谷] [COCI2022-2023#5] Flags
提高+
题目描述

Problem Description

There are $n$ right-angled triangles, where the hypotenuse of the $i$-th triangle is $r_i$, and the sum of their heights does not exceed $S$. Find the maximum total area of these $n$ triangles.

Input Format

The first line contains two integers $n, S$ $(1 \le n \le 10^5, 1 \le S \le 10^{10})$, representing the number of triangles and the maximum sum of their heights.

The second line contains $n$ integers $r_i$ $(1 \le r_i \le 10^5)$.

Output Format

Output the maximum total area of these $n$ right-angled triangles, rounded to 10 decimal places. Your answer is considered correct if the absolute or relative error does not exceed $10^{-6}$.

Sample Input and Output

Sample Input #1

2 3
4 5

Sample Output #1

6.5200982141

Sample Input #2

1 6
10

Sample Output #2

24.0000000000

Sample Input #3

4 7
5 5 6 6

Sample Output #3

18.5706715170

Notes

Explanation for Sample #2:

The maximum possible scenario is that the sides of the triangle are $6, 8, 10$, with an area of $24$.

Subtask Number Additional Constraints Score
0 Sample 0
1 $n \le 100$ 37
2 $n \le 1000$ 20
3 None 43
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 3 4 5
样例输出
6.5200982141