아주 쉬운 문제.. 더 쉽게 풀 수 있을꺼 같은데..
def greedy(N):
counter = [0, 0, 0]
while N > 0:
if N % 300 == 0:
N = N - 300
counter[0] += 1
elif N % 60 == 0:
N = N - 60
counter[1] += 1
elif N % 10 == 0:
N = N - 10
counter[2] += 1
else:
return -1
return counter
ans = greedy(int(input()))
if ans == -1:
print(ans)
else:
for i in range(len(ans)):
print(ans[i], end=" ")
'Algorithm > Greedy' 카테고리의 다른 글
[프로그래머스] 체육복 (0) | 2020.10.09 |
---|---|
[백준] 11047번 동전 0 (0) | 2020.10.07 |
[백준] 14720번 우유 축제 (0) | 2020.10.06 |
[백준] 5585번 거스름돈 (0) | 2020.10.06 |
[백준] 2839번 설탕 배달 (0) | 2020.09.29 |
댓글