Skip to content

Commit

Permalink
Merge pull request #5 from AlgoLeadMe/2-kokeunho
Browse files Browse the repository at this point in the history
2-kokeunho
  • Loading branch information
kokeunho authored Oct 17, 2024
2 parents 8a261a4 + 4a5463f commit 6870c3d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions kokeunho/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
|:----:|:---------:|:----:|:-----:|:----:|
| 1์ฐจ์‹œ | 2024.09.28 | ๊ตฌํ˜„ | [ํ‚น](https://www.acmicpc.net/problem/1063) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/1) |
| 2์ฐจ์‹œ | 2024.10.01 | ๋‹ค์ด๋‚˜๋ฏน ํ”„๋กœ๊ทธ๋ž˜๋ฐ | [ํ‰๋ฒ”ํ•œ ๋ฐฐ๋‚ญ](https://www.acmicpc.net/problem/12865) | [#5] (https://github.com/AlgoLeadMe/AlgoLeadMe-12/pulls/4) |
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
N, K = map(int, input().split())
items = []

for _ in range(N):
W, V = map(int, input().split())
items.append((W, V))

dp = [[0] * (K+1) for _ in range(N+1)]

for i in range(1, N+1):
weight, value = items[i-1]
for j in range(1, K+1):
if j >= weight:
dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight] + value)
else:
dp[i][j] = dp[i-1][j]

print(dp[N][K])





0 comments on commit 6870c3d

Please sign in to comment.