def min_fuel_cost(dist, prices, fuel_tank):
n = len(prices)
fuel = 0
cost = 0
for i in range(n - 1):
need = 0
found = False
for j in range(i + 1, n):
need += dist[j - 1]
if prices[j] < prices[i]:
found = True
break
if found:
target = need
target = fuel_tank
if fuel < target:
buy = target - fuel
cost += buy * prices[i]
fuel = target
fuel -= dist[i]
return cost
dist = [2, 3, 1]
prices = [5, 2, 4, 1]
fuel_tank = 10
print(min_fuel_cost(dist, prices, fuel_tank))
To embed this project on your website, copy the following code and paste it into your website's HTML: