백준 11047

Hyuntae Jung·2022년 8월 30일
0

Algorithm

목록 보기
11/17
post-thumbnail
# A(i)는 A(i-1)의 배수라는 조건이 있으므로 Greedy 적용가능하다.

N, K = map(int, input().split())
coins = [int(input()) for _ in range(N)]
coins.reverse()
ans = 0
for coin in coins:
    ans += K // coin
    K %= coin 
print(ans)

아래와 같은 연산이 수행되어 답이 구해진다.

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

0개의 댓글