cswork / OA打开练习工作台

PaypalOA #3

Find Minimum Price to Spend

估计中等可在线判题

考点(AI 标注)单调栈与堆贪心调度

Buy all items using at most m coupons. After applying x coupons in a row to one price, the price becomes floor(price/2^x). Each coupon can be used for at most one halving of one item.

输入格式

The first line contains n m; the second line contains n positive integer prices. The source lacks constraints; added by this site: 1≤n≤100000, 0≤m≤10^9, 1≤price[i]≤10^9; the total price and the answer are output as 64-bit integers.

输出格式

Output the minimum total price to buy all items after using coupons.

样例 1

输入:

3 2
1 2 3

输出:

3

样例 2

输入:

2 2
2 4

输出:

3

样例 3

输入:

2 0
5 1

输出:

6