class Solution:
def coinChange(self, coins, amount):
"""
:type coins: List[int]
:type amount: int
:rtype: int
"""
MAX = float('inf')
# 初始条件dp[0]=0
dp = [0] + [MAX] * amount
for i in range(1, amount + 1):
# 状态转移方程dp[i] = min(dp[i - c] for c in coins)
dp[i] = min([dp[i - c] if i - c >= 0 else MAX for c in coins]) + 1
return [dp[amount], -1][dp[amount] == MAX]