COCI '22 Contest 5 #5 Zastave

View as PDF

Submit solution


Points: 17 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type

After an exhausting day of preparing COCI, after sleeping for only three hours and in intervals of 20 minutes, and finally after naughty Patrick and Josip got on his nerves, Vito fell asleep.

Vito was always a pacifist and as a sign of his resignation in front of the disobedience of his (un)reliable friends, Vito dreamed of n white flags. Each white flag had the shape of a right triangle swirling in the air with one of its sides parallel to the ground. In the morning, Vito could only remember a few key details... the length of the hypotenuse of the i-th flag was r_i and the total sum of heights of the flags was at most S.

Now awake, he decided he shall fight on the beaches and never surrender! He rushed to the nearest paint shop so that the next time he dreams of the n white flags he can paint them over! But he quickly realized, he isn't sure how much paint he has to buy. So he asked you to calculate the maximum possible total area of the n white flags satisfying the constraints!

Input Specification

The first line contains the integers n and S (1 \le n \le 100\,000, 1 \le S \le 10^{10}), the number of flags and the maximum possible sum of heights of the flags.

In the next line there are n integers r_i (1 \le r_i \le 100\,000).

Output Specification

In the only line, output the maximum possible sum of areas of the flags. Your solution will be considered correct if the absolute or relative error is smaller than 10^{-6}.

Constraints

Subtask Points Constraints
1 41 n \le 100
2 22 n \le 1\,000
3 47 No additional constraints.

Sample Input 1

2 3
4 5

Sample Output 1

6.5200982141

Sample Input 2

1 6
10

Sample Output 2

24.0000000000

Explanation for Sample 2

The largest possible area is achieved by a flag with sides 6, 8, and 10, and the total area is 24.

Sample Input 3

4 7
5 5 6 6

Sample Output 3

18.5706715170

Comments

There are no comments at the moment.