Submit solution
Points:
15 (partial)
Time limit:
1.4s
Rust
2.5s
Memory limit:
64M
Authors:
Problem type
After returning from the nautical lessons, Captain Akeno asked her good friend
to go and get her some more shoes while she is at school, from the same shop. When arrived at the store, he observed some deals. The deals are as follows:- If you group two pairs of shoes, you get the cheaper one at a 50% discount.
- If you group three pairs of shoes, you get the cheapest one for free.
, which represents that she needs to get the -th smallest unique obtainable price from grouping the pairs. How much money is going to pay?
is rather lazy, and doesn't really care about the best price, so he asked the cashier to group the pairs as she sees fit. The cashier can only group adjacent pairs in the order placed them on the conveyor. Additionally, the cashier is instructed with a special number,Input Specification
The first line of input will contain two space-separated integers, () and ().
The second line of input will contain space-separated integers representing the prices of the pairs of shoes. It is guaranteed that the total sum of the numbers does not exceed .
Output Specification
On the first line, you must print the -th smallest unique obtainable price with one decimal. In case you can't find an answer, print -1
.
Sample Input
5 3
100 27 15 25 400
Sample Output
541.0
Comments
I be Spendin' dat dollas on mah shoes homie. Idk about u but I roll big