#abc374f. F - Shipping
F - Shipping
Score : points
问题陈述
KEYENCE 以快速交货而闻名。
在这个问题中,日历按照第 天,第 天,第 天, 进行。
有订单 ,并且已知订单 将在第 天下单。 对于这些订单,根据以下规则进行发货。
- 最多可以一起发货 个订单。
- 订单 只能在第 天或之后发货。
- 一旦发货,必须等待 天后才能进行下一次发货。
- 也就是说,如果在第 天发货,下一次发货可以在第 天进行。
从订单下单到发货的每一天,不满情绪会累积增加 。 也就是说,如果订单 在第 天发货,那么该订单累积的不满情绪是 。
当你最优地安排发货日期时,找出所有订单累积的最小可能总不满情绪。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
KEYENCE is famous for quick delivery.
In this problem, the calendar proceeds as Day , Day , Day , .
There are orders , and it is known that order will be placed on Day .
For these orders, shipping is carried out according to the following rules.
- At most orders can be shipped together.
- Order can only be shipped on Day or later.
- Once a shipment is made, the next shipment cannot be made until days later.
- That is, if a shipment is made on Day , the next shipment can be made on Day .
For each day that passes from order placement to shipping, dissatisfaction accumulates by per day.
That is, if order is shipped on Day , the dissatisfaction accumulated for that order is .
Find the minimum possible total dissatisfaction accumulated over all orders when you optimally schedule the shipping dates.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
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 , which is the minimum possible.
- Ship order on Day .
- This results in dissatisfaction of , and the next shipment can be made on Day .
- Ship orders and on Day .
- This results in dissatisfaction of , and the next shipment can be made on Day .
- Ship order on Day .
- This results in dissatisfaction of , and the next shipment can be made on Day .
- Ship order on Day .
- This results in dissatisfaction of , and the next shipment can be made on Day .
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
相关
在下列比赛中: