This commit is contained in:
nik
2025-10-01 22:55:09 +03:00
parent 4d0ece634b
commit 74e98c37c4
591 changed files with 20286 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
def greedy_change(n, coins):
result = []
for value, count in sorted(coins, key=lambda x: -x[0]):
while count > 0 and n >= value:
n -= value
count -= 1
result.append(value)
return result if n == 0 else None
if __name__ == "__main__":
coins = [(10, 3), (5, 2), (2, 5), (1, 10)]
N = 28
print(greedy_change(N, coins))