Skip to content

Commit ea08905

Browse files
authored
feat: 3월 2주차 과제 문제 답
1 parent e4858cb commit ea08905

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'''
2+
BOJ #2294. 동전 2 (골드 5)
3+
https://www.acmicpc.net/problem/2294
4+
유형: DP
5+
'''
6+
7+
8+
for _ in range(n):
9+
arr.append(int(input()))
10+
11+
dp = [100001 for i in range(k + 1)]
12+
dp[0] = 0
13+
14+
for coin in arr:
15+
for i in range(coin, k + 1):
16+
dp[i] = min(dp[i], dp[i - coin] + 1)
17+
18+
if dp[k] == 100001:
19+
print(-1)
20+
else:
21+
print(dp[k])

0 commit comments

Comments
 (0)