atcoder#ABC246C. [ABC246C] Coupon

[ABC246C] Coupon

Score : 300300 points

Problem Statement

There are NN items in a shop. For each i=1,2,,Ni = 1, 2, \ldots, N, the price of the ii-th item is AiA_i yen (the currency of Japan).

Takahashi has KK coupons. Each coupon can be used on one item. You can use any number of coupons, possibly zero, on the same item. Using kk coupons on an item with a price of aa yen allows you to buy it for max{akX,0}\max\lbrace a - kX, 0\rbrace yen.

Print the minimum amount of money Takahashi needs to buy all the items.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 1K,X1091 \leq K, X \leq 10^9
  • 1Ai1091 \leq A_i \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK XX

A1A_1 A2A_2 \ldots ANA_N

Output

Print the answer.

5 4 7
8 3 10 5 13
12

By using 11 coupon on the 11-st item, 11 coupon on the 33-rd item, and 22 coupons on the 55-th item, Takahashi can:

  • buy the 11-st item for max{A1X,0}=1\max\lbrace A_1-X, 0 \rbrace = 1 yen,
  • buy the 22-nd item for max{A2,0}=3\max\lbrace A_2, 0 \rbrace = 3 yen,
  • buy the 33-rd item for max{A3X,0}=3\max\lbrace A_3-X, 0 \rbrace = 3 yen,
  • buy the 44-th item for max{A4,0}=5\max\lbrace A_4, 0 \rbrace = 5 yen,
  • buy the 55-th item for max{A52X,0}=0\max\lbrace A_5-2X, 0 \rbrace = 0 yen,

for a total of 1+3+3+5+0=121 + 3 + 3 + 5 + 0 = 12 yen, which is the minimum possible.

5 100 7
8 3 10 5 13
0
20 815 60
2066 3193 2325 4030 3725 1669 1969 763 1653 159 5311 5341 4671 2374 4513 285 810 742 2981 202
112