#P9749. [CSP-J 2023] 公路
[CSP-J 2023] 公路
Problem Description
Xiaobao plans to drive along a highway for a road trip.
There are a total of stations on the highway, numbered from to . The distance between station and station is kilometers.
At every station, you can refuel. At station , the price per liter is yuan, and each station sells only an integer number of liters.
Xiaobao wants to drive from station to station . At the beginning, Xiaobao is at station and the fuel tank is empty. It is known that the fuel tank is large enough to hold any amount of fuel, and each liter of fuel allows the car to travel kilometers. Find the minimum cost of refueling needed for Xiaobao to drive from station to station .
Input Format
The first line contains two positive integers and , representing the number of stations on the highway and the distance the car can travel per liter of fuel.
The second line contains positive integers , representing the distances between adjacent stations.
The third line contains positive integers , representing the refueling price at each station.
Output Format
Output one line containing only one positive integer, representing the minimum money Xiaobao needs to spend on refueling to drive from station to station .
5 4
10 10 10 10
9 8 9 6 5
79
Hint
[Sample 1 Explanation]
In the optimal plan: Xiaobao buys liters at station , buys liters at station , and buys liters at station .
[Sample 2]
See road/road2.in and road/road2.ans under the contestant directory.
[Constraints]
For all testdata, it is guaranteed that: , , , .
::cute-table{tuack}
| Test Point | Special Property | |
|---|---|---|
| None | ||
| ^ | ||
| A | ||
| ^ | B | |
| None |
- Special Property A: Station has the lowest fuel price.
- Special Property B: For all , is a multiple of .
Translated by ChatGPT 5