#P10428. [蓝桥杯 2024 省 B] 爬山
[蓝桥杯 2024 省 B] 爬山
Problem Description
This problem is suspected to be incorrect. So far, there is no algorithm that can produce the correct solution for all inputs within the given time limit.
Xiaoming is taking part in a company team-building activity, and the activity is mountain climbing. On the axis, there are mountains from left to right. The height of the -th mountain is . They need to climb all the mountains from left to right in order, and the stamina cost is .
However, Xiaoming secretly learned magic that can reduce the heights of some mountains. He knows two types of magic. The first type can change the height of a mountain with height to , and it can be used times. The second type can change the height of a mountain with height to , and it can be used times. For each mountain, these two types of magic can be cast multiple times in any order.
Xiaoming wants to plan which mountains to use magic on so that the stamina cost of climbing is minimized. What is the minimum possible stamina cost in the optimal case?
Input Format
The input has two lines.
The first line contains three integers , , .
The second line contains integers , , , .
Output Format
Output one line with one integer, which is the answer.
4 1 1
4 5 6 49
18
Hint
- For of the testdata, , .
- For all testdata, it is guaranteed that , , .
Translated by ChatGPT 5