Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- pricelist = [0, 5, 2, 18, 3, 24, 15, 8, 10]
- price = [0] * (n + 1)
- price[1] = pricelist[1]
- price[2] = pricelist[2]
- for i in range (3, n + 1):
- price[i] = min(price[i - 1], price[i - 2]) + pricelist[i]
- print(price[n])
Advertisement
Add Comment
Please, Sign In to add comment