| VIII MaratonUSP Freshman Contest |
|---|
| Finished |
Byakronos was organizing the first marathon contest. However, near the beginning of the competition, he realized that there weren't enough balloons!
Because of this, Byakronos sent Mori to get balloons from the MaratonUSP's carriage. Fortunately, Mori came across the shop of the God Helios, which sells 'quantum' balloons. So, Mori bought inflated balloons (to save time!) of $$$N$$$ colors, where $$$b_i$$$ balloons of color $$$i$$$ $$$(1 \leq i \leq N)$$$ were purchased.
When Mori loaded the balloons onto the truck, he realized that the carriage could hold a maximum of $$$S$$$ inflated balloons. Thus, Mori needs to deflate balloons so that there are at most $$$S$$$ inflated balloons left.
As the balloons are quantum, they only deflate if Mori looks at them. Furthermore, the inflated balloons follow the rules of radioactive decay, with a half-life of $$$1$$$ second. In other words, every $$$1$$$ second Mori looks at $$$x$$$ inflated balloons, $$$\left \lfloor \frac{x}{2} \right\rfloor$$$ will still be inflated at the end of that second.
Therefore, to deflate the balloons, Mori will choose a color $$$i$$$ every second and look at balloons of that color for exactly $$$1$$$ second (if Mori were to look at more than one color, he'd lose track!).
Clearly, looking at quantum balloons for too long is not healthy. So, Mori wonders, what is the minimum number of seconds needed for at most $$$S$$$ inflated balloons to remain?
Input consists of 2 lines.
The first line contains two integers $$$N, S$$$ ($$$1 \leq N \leq 10^5, 0 \leq S \leq 10^9$$$) separated by a space - representing the number of balloon colors and the maximum number of inflated balloons the truck can hold, respectively.
The second line contains $$$N$$$ integers $$$b_1, b_2, \dots, b_N$$$ $$$(1 \leq b_i \leq 10^9)$$$ - representing the quantity of balloons of each color purchased.
Print an integer, the minimum number of seconds needed for there to be at most $$$S$$$ inflated balloons remaining.
2 5 3 5
1
5 0 1 1 1 1 1
5
| Name |
|---|


