๐Ÿ˜Š ๋ฐฑ์ค€ 11047 : ๋™์ „ 0

11047: ๋™์ „ 0

Greedy ์ฒซ ๋ฌธ์ œ!
๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ๋กœ ์‹œ์ž‘ํ–ˆ๋‹ค.


๐Ÿ“Œ Try 1

N, K = map(int, input().split())
coin, cnt = list(), 0

for _ in range(N):
    coin.append(int(input()))

for i in sorted(coin, reverse=True):
    num = K // i    # ๋™์ „ ๊ฐฏ์ˆ˜
    cnt += num 
    K %= i
    
print(cnt)

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ