#abc246c. C - Coupon

C - Coupon

Score : 300300 points

问题描述

商店里有 NN 件商品。对于每一件商品 i=1,2,,Ni = 1, 2, \ldots, N,第 ii 件商品的价格是 AiA_i 日元(日本货币单位)。

高桥有 KK 张优惠券。
每张优惠券可以用于一件商品上。你可以对同一件商品使用任意数量的优惠券,甚至可以不使用优惠券。在价格为 aa 日元的商品上使用 kk 张优惠券后,你能够以 max{akX,0}\max\lbrace a - kX, 0\rbrace 日元的价格购买它。

请输出高桥购买所有商品所需的最小金额。

以上为通义千问 qwen-max 翻译,仅供参考。

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.

Sample Input 1

5 4 7
8 3 10 5 13

Sample Output 1

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.

Sample Input 2

5 100 7
8 3 10 5 13

Sample Output 2

0

Sample Input 3

20 815 60
2066 3193 2325 4030 3725 1669 1969 763 1653 159 5311 5341 4671 2374 4513 285 810 742 2981 202

Sample Output 3

112

update @ 2024/3/10 10:33:17

}