소스코드
N,K = map(int,input().split())
cnt = 0
coin = []
for i in range(N):
money = int(input())
coin.append(money)
coin.sort(reverse = True)
for i in coin:
if K >= (K//i)*i : #큰 수부터 몫연산 2560 // 1000 = 2 -> 2560 - 2000
cnt += K//i #답에 올린 코인 개수 추가 ex) 2개
K = K - (K//i)*i #계산 대상 돈 리셋
print(cnt)
'Coding test' 카테고리의 다른 글
[백준/14888/파이썬] 연산자 끼워넣기 (0) | 2023.05.14 |
---|---|
[백준/12845/파이썬] 모두의 마블 (0) | 2023.02.28 |
[백준/18290/파이썬] NM과 K (1) (0) | 2023.02.27 |
[백준/15655/파이썬] N과 M (6) (0) | 2023.02.23 |
[백준/15654/파이썬] N과 M (5) (0) | 2023.02.21 |