Notice
Recent Posts
Recent Comments
Link
나의 개발일지
[백준] 2294번 동전 2 [Python] 본문
- 문제 : https://www.acmicpc.net/problem/2294
- Dynamic Programming (DP)
n, m = map(int, input().split())
coins = [int(input()) for _ in range(n)]
dp = [10001] * (m + 1)
dp[0] = 0
for c in coins:
for i in range(c, m+1):
dp[i] = min(dp[i], dp[i - c] + 1)
if dp[m] != 10001:
print(dp[m])
else:
print(-1)
'백준' 카테고리의 다른 글
[백준] 1111번 IQ Test [Python, 파이썬] (0) | 2023.09.04 |
---|---|
[백준] 13305번 주유소 [Python] (0) | 2023.08.04 |
[백준] 1939번 중량제한 [Python] (0) | 2023.08.04 |
[백준] 2638번 치즈 [Python] (0) | 2023.08.02 |
[백준] 7576번 토마토 [Python] (0) | 2023.07.31 |
Comments