#abc318c. C - Blue Spring
C - Blue Spring
Score : points
问题描述
高桥正在计划一次 天的火车旅行。
对于每一天,他可以选择支付正常票价或者使用一日通票。
这里,对于 ,旅行第 天的正常票价为 日元。
另一方面,一组包含 张的一日通票售价为 日元。你可以任意购买通票,但必须按 的整数倍购买。
每张购买的通票可以在任何一天使用,并且在旅行结束时剩余一些通票也是可以接受的。
请你找出 天旅行所需的最小总花费,即购买一日通票的费用加上未被一日通票覆盖的天数的正常票价之和。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi is planning an -day train trip.
For each day, he can pay the regular fare or use a one-day pass.
Here, for , the regular fare for the -th day of the trip is yen.
On the other hand, a batch of one-day passes is sold for yen. You can buy as many passes as you want, but only in units of .
Each purchased pass can be used on any day, and it is fine to have some leftovers at the end of the trip.
Find the minimum possible total cost for the -day trip, that is, the cost of purchasing one-day passes plus the total regular fare for the days not covered by one-day passes.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the minimum possible total cost for the -day trip.
Sample Input 1
5 2 10
7 1 6 3 6
Sample Output 1
20
If he buys just one batch of one-day passes and uses them for the first and third days, the total cost will be , which is the minimum cost needed.
Thus, print .
Sample Input 2
3 1 10
1 2 3
Sample Output 2
6
The minimum cost is achieved by paying the regular fare for all three days.
Sample Input 3
8 3 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
Sample Output 3
3000000000
The minimum cost is achieved by buying three batches of one-day passes and using them for all eight days.
Note that the answer may not fit into a -bit integer type.
update @ 2024/3/10 09:04:30