2361. Minimum Costs Using the Train Line
On This Page
class Solution:
def minimumCosts(
self, regular: List[int], express: List[int], expressCost: int
) -> List[int]:
n = len(regular)
f, g = 0, inf
cost = [0] * n
for i, (a, b) in enumerate(zip(regular, express), 1):
ff = min(f + a, g + a)
gg = min(f + expressCost + b, g + b)
f, g = ff, gg
cost[i - 1] = min(f, g)
return cost