[백준] 11047번 : 동전 0 (Python)
2023. 3. 12. 01:01ㆍ알고리즘/그리디
https://www.acmicpc.net/problem/11047
11047번: 동전 0
첫째 줄에 N과 K가 주어진다. (1 ≤ N ≤ 10, 1 ≤ K ≤ 100,000,000) 둘째 줄부터 N개의 줄에 동전의 가치 Ai가 오름차순으로 주어진다. (1 ≤ Ai ≤ 1,000,000, A1 = 1, i ≥ 2인 경우에 Ai는 Ai-1의 배수)
www.acmicpc.net
문제 유형
- 그리디 알고리즘


내 코드
n,k= map(int,input().split())
coin_cnt=0
coin=[]
for i in range(n):
a=int(input())
coin.append(a)
coin = sorted(coin,reverse=True)
for i in coin:
coin_cnt+= k // i
k%=i
print(coin_cnt)

'알고리즘 > 그리디' 카테고리의 다른 글
[백준] 13305번 : 주유소 (Python) (0) | 2023.03.15 |
---|---|
[백준] 2217번 : 로프 (Python) (0) | 2023.03.13 |
[백준] 11399번 : ATM (Python) (0) | 2023.03.13 |
[백준] 1343번 : 폴로노미오 (Python) (0) | 2023.03.11 |
[백준] 5585번 : 거스름돈 (Python) (0) | 2023.03.11 |