Skip to content

[BOJ/골드5] 22-10-13 (평범한 배낭)#20

Merged
hyesuuou merged 1 commit into
mainfrom
hyesu
Oct 13, 2022
Merged

[BOJ/골드5] 22-10-13 (평범한 배낭)#20
hyesuuou merged 1 commit into
mainfrom
hyesu

Conversation

@hyesuuou

Copy link
Copy Markdown
Collaborator

🌱 문제번호와 링크

https://www.acmicpc.net/problem/12865

🥺 무엇을 알게 되었나요?

받은 아이템을 하나씩 돌면서 체크한다.
d[i][j] -> i번째 아이템까지 넣었을 때 j무게일때 최대가치

if j < w: # 무게가 더 클때는 물건을 못넣는다. -> 이전 가치를 넣는다.
       d[i][j] = d[i-1][j]
else: # 넣을 수 있으면 이전거랑 넣은 가치랑 중에 최대를 넣는다
      d[i][j] = max(d[i-1][j-w] + v, d[i-1][j])

.. 아직 혼자풀라하면 못풀겠음요

@hyesuuou hyesuuou self-assigned this Oct 13, 2022
@hyesuuou hyesuuou merged commit aa3e6b2 into main Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant