-
[Python] 백준 - 11047 동전 0__Python/__Algorithm 2021. 12. 20. 20:04
# 백준 Silver2
# 11047 동전 0
[문제]
링크 : https://www.acmicpc.net/problem/11047
[문제 풀이]
그리디
[구현 코드]
import sys N,K = map(int,sys.stdin.readline().split()) coins = [int(sys.stdin.readline()) for _ in range(N)] ans = 0 coins.sort(reverse=True) for i in range(len(coins)): if coins[i] <= K: ans += K//coins[i] K = K - coins[i]* (K//coins[i]) if K == 0 : break print(ans)
[실행 결과]
728x90'__Python > __Algorithm' 카테고리의 다른 글
[Python] 백준 - 9184 신나는 함수 실행 (0) 2021.12.21 [Python] 백준 - 1003 피보나치 함수 (0) 2021.12.21 [Python] 백준 - 1874 스택 수열 (0) 2021.12.20 [python] 백준 - 1654 랜선자르기 (0) 2021.12.20 [python] 프로그래머스 - 87946 피로도 (0) 2021.11.16