Skip to content

Commit 6d01bb8

Browse files
authored
Create 1535.py
1 parent 816a1e5 commit 6d01bb8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

2주차 Knapsack/손영준/1535.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
n = int(input()) #사람의 수
2+
H = [0] + list(map(int, input().split())) #health
3+
J = [0] + list(map(int, input().split())) #joyful
4+
# list 1부터 시작.
5+
6+
#dp 테이블
7+
dp = [[0]* 101 for _ in range(n+1)]
8+
9+
for x in range(1,n+1):
10+
h = H[x]
11+
j = J[x]
12+
for y in range(1,101):
13+
if y < h: #현재 사람 x
14+
dp[x][y] = dp[x-1][y]
15+
else: #현재 사람 o
16+
dp[x][y] = max(dp[x-1][y], dp[x-1][y-h]+ j)
17+
18+
print(dp[n][99])

0 commit comments

Comments
 (0)