#abc374f. F - Shipping

F - Shipping

Score : 550550 points

问题陈述

KEYENCE 以快速交货而闻名。

在这个问题中,日历按照第 11 天,第 22 天,第 33 天,\dots 进行。

有订单 1,2,,N1,2,\dots,N,并且已知订单 ii 将在第 TiT_i 天下单。 对于这些订单,根据以下规则进行发货。

  • 最多可以一起发货 KK 个订单。
  • 订单 ii 只能在第 TiT_i 天或之后发货。
  • 一旦发货,必须等待 XX 天后才能进行下一次发货。
    • 也就是说,如果在第 aa 天发货,下一次发货可以在第 a+Xa+X 天进行。

从订单下单到发货的每一天,不满情绪会累积增加 11。 也就是说,如果订单 ii 在第 SiS_i 天发货,那么该订单累积的不满情绪是 (SiTi)(S_i - T_i)

当你最优地安排发货日期时,找出所有订单累积的最小可能总不满情绪。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

KEYENCE is famous for quick delivery.

In this problem, the calendar proceeds as Day 11, Day 22, Day 33, \dots.

There are orders 1,2,,N1,2,\dots,N, and it is known that order ii will be placed on Day TiT_i.
For these orders, shipping is carried out according to the following rules.

  • At most KK orders can be shipped together.
  • Order ii can only be shipped on Day TiT_i or later.
  • Once a shipment is made, the next shipment cannot be made until XX days later.
    • That is, if a shipment is made on Day aa, the next shipment can be made on Day a+Xa+X.

For each day that passes from order placement to shipping, dissatisfaction accumulates by 11 per day.
That is, if order ii is shipped on Day SiS_i, the dissatisfaction accumulated for that order is (SiTi)(S_i - T_i).

Find the minimum possible total dissatisfaction accumulated over all orders when you optimally schedule the shipping dates.

Constraints

  • All input values are integers.
  • 1KN1001 \le K \le N \le 100
  • 1X1091 \le X \le 10^9
  • 1T1T2TN10121 \le T_1 \le T_2 \le \dots \le T_N \le 10^{12}

Input

The input is given from Standard Input in the following format:

NN KK XX

T1T_1 T2T_2 \dots TNT_N

Output

Print the answer as an integer.

Sample Input 1

5 2 3
1 5 6 10 12

Sample Output 1

2

For example, by scheduling shipments as follows, we can achieve a total dissatisfaction of 22, which is the minimum possible.

  • Ship order 11 on Day 11.
    • This results in dissatisfaction of (11)=0(1-1) = 0, and the next shipment can be made on Day 44.
  • Ship orders 22 and 33 on Day 66.
    • This results in dissatisfaction of (65)+(66)=1(6-5) + (6-6) = 1, and the next shipment can be made on Day 99.
  • Ship order 44 on Day 1010.
    • This results in dissatisfaction of (1010)=0(10-10) = 0, and the next shipment can be made on Day 1313.
  • Ship order 55 on Day 1313.
    • This results in dissatisfaction of (1312)=1(13-12) = 1, and the next shipment can be made on Day 1616.

Sample Input 2

1 1 1000000000
1000000000000

Sample Output 2

0

Sample Input 3

15 4 5
1 3 3 6 6 6 10 10 10 10 15 15 15 15 15

Sample Output 3

35