무제
[백준] 그리디 알고리즘 : 5585번 거스름돈 본문
브론즈 레벨의 문제지만 그리디 알고리즘의 대표적인 문제인 것 같아
다시 한 번 풀어봤다(나에게는 이 문제도 쉽지 않다...)
import sys
input = sys.stdin.readline
price = int(input())
left = 1000 - price
coins = [500, 100, 50, 10, 5, 1]
cnt = 0
for coin in coins:
cnt += left // coin
left = left % coin
if left <= 0 : break
print(cnt)
'Study > Coding Test 오답노트' 카테고리의 다른 글
| [백준] 1406번 에디터 (0) | 2024.11.09 |
|---|---|
| [백준] 자료구조 - 9012(괄호) / 1874(스택 수열) (0) | 2024.10.19 |
| 백준 알고리즘 공부 순서 (0) | 2024.10.19 |
| [백준] 덱 10866 / 그리디 1439 (0) | 2024.09.21 |
| [Programmers] [3차] n진수 게임 (1) | 2024.09.02 |
Comments