728x90
반응형

문제

https://www.acmicpc.net/problem/10162

문제 접근

가장 적은 횟수로 시간을 채우라는 문제이다. 역시 그리디로 접근할 수 있다.

 

코드

t= int(input())

times = [300,60,10]
result = list()

for time in times:
    if t//time > 0:
        result.append(t//time)
        t = t%time
    else:
        result.append(0)
        
for r in result:
    if t == 0:
        print(r, end=' ')
    else:
        print(-1)
        break

 

배운점

그리디 문제는 리스트과 정렬!

728x90
반응형

+ Recent posts