usr bin env python3 total int input banknotes int value for value in i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#!/usr/bin/env python3
total = int(input())
banknotes = [int(value) for value in input().split()]
dp = [0] + [float('inf')] * total
for amount in range(total + 1):
for banknote in banknotes:
if amount >= banknote:
dp[amount] = min(dp[amount], 1 + dp[amount - banknote])
print(dp[total])