#P2094. 运输

运输

Description

There are NN goods, and the handling fee for each of them is known. The moving company boss, Mr. sb, decides that each time we can arbitrarily pick 22 goods. Then these 22 goods count as only one item’s fee, where the new item’s handling fee is the result of dividing the sum of the two selected items’ fees by kk. Repeat this process until only one item’s fee remains. This final amount is what the shop has to pay. The shopkeeper wants to pay as little as possible so that more money can be donated to Project Hope (Xiwang Gongcheng). Please help compute the minimum amount that needs to be paid.

Input Format

The first line contains two integers n,kn, k.

The second line contains nn integers w1,w2,,wnw_1, w_2, \ldots, w_n, representing the handling fee of each item.

Output Format

Output a single integer, the minimum amount that needs to be paid.

5 2
1 2 3 4 5
1

Hint

n,k,win, k, w_i are all non-negative.

n,k104n, k \le 10^4.


upd 2022.7.24\text{upd 2022.7.24}: Added one set of Hack testdata. Whether there exists a correct solution within this constraint range is controversial.

Translated by ChatGPT 5