#P9749. Minimum Fuel Cost
Minimum Fuel Cost
Minimum Fuel Cost
You are given a road with n gas stations numbered from 1 to n. The distance between station i and station i+1 is given by \(v_i\) kilometers. At each station i, the cost for one liter of fuel is \(a_i\) (in yuan), and you can only purchase an integer number of liters. Your car’s tank has unlimited capacity but starts empty at station 1. One liter of fuel allows the car to travel \(d\) kilometers. Your goal is to travel from station 1 to station n with a minimum total cost by refueling appropriately along the way.
Note: When calculating the amount of fuel required to cover a distance \(X\) kilometers, you must purchase \(\lceil X/d \rceil\) liters (since fractional liters cannot be bought). All formulas are presented in \(\LaTeX\) format.
inputFormat
The input consists of three lines:
- The first line contains two integers \(n\) and \(d\), where \(n\) is the number of stations and \(d\) is the distance (in kilometers) one liter of fuel can drive.
- The second line contains \(n\) integers: \(a_1, a_2, \ldots, a_n\) representing the price of one liter of fuel at each station.
- The third line contains \(n-1\) integers: \(v_1, v_2, \ldots, v_{n-1}\) representing the distances (in kilometers) between consecutive stations.
outputFormat
Output a single integer representing the minimum total cost to travel from station 1 to station \(n\).
sample
4 10
5 2 4 1
10 20 10
11