#P3399. 丝绸之路
丝绸之路
Description
A little hamster is delivering goods from China to Baghdad. The Silk Road has cities including the start and the end. City is the starting point Chang’an, and city is the destination Baghdad. The hamster must reach the destination in at most days. In one day, it is possible to travel from one city to the next consecutive city. The distance from city to city is .
As everyone knows, traveling continuously is exhausting, so when staying in a city, the hamster has two choices:
- Move: set off toward the next city.
- Rest: stay in the current city without moving.
Desert weather is unpredictable. When the weather is bad, moving forward is much more difficult. Let the severity of the weather on the -th day () be . If the hamster moves from city to city on day , it incurs a fatigue of .
However, the hamster can choose to avoid worse weather; resting consumes no fatigue. Now it wants to know the minimum total fatigue for the whole trip.
Input Format
The first line contains integers and .
The next lines each contain one integer .
The next lines each contain one integer .
Output Format
Output a single integer, the minimal total fatigue.
3 5
10
25
15
50
30
15
40
30
1125
Hint
Sample Explanation
Rest on day .
On day , , fatigue .
On day , , fatigue .
Rest on day .
On day , , fatigue .
Constraints
.
.
Translated by ChatGPT 5
京公网安备 11011102002149号