문제풀이/백준(Boj) 문제풀이

[백준][그리디 알고리즘] 5585. 거스름돈(파이썬/Python)

얄루몬 2021. 9. 30. 14:20

import sys
input = sys.stdin.readline

n = int(input())
coin = [500,100,50,10,5,1]
charge = 1000-n
result = 0
for i in coin:
    result += charge//i
    charge = charge%i
print(result)