2361. Minimum Costs Using the Train Line
Authority (To do or not to do)
class Solution:
def minimumCosts(self, regular: List[int], express: List[int], expressCost: int) -> List[int]:
n = len(regular)
dp = [[0] * 2 for i in range(n+1)]
dp[0][1] = expressCost
regular = [0] + regular
express = [0] + express
res = []
for i in range(1, n+1):
dp[i][0] = min(dp[i-1][0] + regular[i], dp[i-1][1] + express[i])
dp[i][1] = min(dp[i-1][1] + express[i], dp[i-1][0] + regular[i] + expressCost)
res.append(min(dp[i]))
return res