cswork / OAOpen practice workspace

SnowflakeOA #4

Minimum Total Weight

Estimated MediumJudge-ready

Topics (AI-labelled)Stacks & HeapsGreedy

Each day, choose one piece and eat floor(w/2) of it, leaving ceil(w/2); the same piece may be chosen repeatedly. Find the minimum total weight after d days.

Input

The first line contains n d, and the second line contains n weights; n≤100000, 1≤w≤10000, 1≤d≤2000000.

Output

Output the single integer required by the problem.

Example 1

Input:

3 4
30 20 25

Output:

31

Example 2

Input:

1 1
2

Output:

1

Example 3

Input:

2 1
2 3

Output:

4

Example notes

The answers to the three public examples are, in order: 31; 1; 4. All examples have been verified by independent small-scale enumeration or state search.

Editorial

Loading solution…