100 atcoder#ABC141D. [ABC141D] Powerful Discount Tickets

[ABC141D] Powerful Discount Tickets

Score : 400400 points

Problem Statement

Takahashi is going to buy NN items one by one.

The price of the ii-th item he buys is AiA_i yen (the currency of Japan).

He has MM discount tickets, and he can use any number of them when buying an item.

If YY tickets are used when buying an item priced XX yen, he can get the item for X2Y\frac{X}{2^Y} (rounded down to the nearest integer) yen.

What is the minimum amount of money required to buy all the items?

Constraints

  • All values in input are integers.
  • 1N,M1051 \leq N, M \leq 10^5
  • 1Ai1091 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 ...... ANA_N

Output

Print the minimum amount of money required to buy all the items.

3 3
2 13 8
9

We can buy all the items for 99 yen, as follows:

  • Buy the 11-st item for 22 yen without tickets.
  • Buy the 22-nd item for 33 yen with 22 tickets.
  • Buy the 33-rd item for 44 yen with 11 ticket.
4 4
1 9 3 5
6
1 100000
1000000000
0

We can buy the item priced 10000000001000000000 yen for 00 yen with 100000100000 tickets.

10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
9500000000