Advertisement
zhukov000

Stairway

Nov 22nd, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. n = int(input())
  2. dp = [0] * (n + 1)
  3. cost = [0] + [int(x) for x in input().split()]
  4. dp[1] = cost[1]
  5.  
  6. for i in range(2, n+1):
  7.   dp[i] = min(dp[i-1], dp[i-2]) + cost[i]
  8.  
  9. print(dp[n])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement