Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] main from itcharge:main #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 18 commits into AlgorithmAndLeetCode:main from itcharge:main
Mar 22, 2023
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
460d75d
Update Pack-CompletePack.py
itcharge Mar 21, 2023
1ae40b1
Create Pack-MultiplePack.py
itcharge Mar 21, 2023
3d4e8ce
Update 02.Knapsack-Problem-02.md
itcharge Mar 21, 2023
266cfd3
Update 03.Knapsack-Problem-03.md
itcharge Mar 21, 2023
3f1e5f4
Update Pack-CompletePack.py
itcharge Mar 21, 2023
34ab7ce
Update Pack-MultiplePack.py
itcharge Mar 21, 2023
f3dcb25
Update Pack-ZeroOnePack.py
itcharge Mar 21, 2023
24720ec
Update 01.Knapsack-Problem-01.md
itcharge Mar 21, 2023
02afef9
Update 02.Knapsack-Problem-02.md
itcharge Mar 21, 2023
9e97a03
Update 03.Knapsack-Problem-03.md
itcharge Mar 21, 2023
9142635
Update Pack-CompletePack.py
itcharge Mar 22, 2023
26a4961
Update Pack-MultiplePack.py
itcharge Mar 22, 2023
65a6ae5
Update Pack-ZeroOnePack.py
itcharge Mar 22, 2023
41eafdb
Update 01.Knapsack-Problem-01.md
itcharge Mar 22, 2023
de5b1d2
Update 02.Knapsack-Problem-02.md
itcharge Mar 22, 2023
7d6a654
Update 03.Knapsack-Problem-03.md
itcharge Mar 22, 2023
f8b4487
Update 04.Knapsack-Problem-04.md
itcharge Mar 22, 2023
7d44e7f
Update 03.Knapsack-Problem-03.md
itcharge Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update Pack-CompletePack.py
  • Loading branch information
itcharge committed Mar 21, 2023
commit 460d75d72557fcc2ed81cf2dfdc7bc5881b00ece
4 changes: 2 additions & 2 deletions Templates/10.Dynamic-Programming/Pack-CompletePack.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def completePack(self, weight: [int], value: [int], W: int):
for w in range(1, W + 1):
# 枚举第 i 种物品能取个数
for k in range(w // weight[i - 1] + 1):
# dp[i][w] 取所有 dp[i][w - k * weight[i - 1] + k * value[i - 1] 中最大值
dp[i][w] = max(dp[i][w], dp[i][w - k * weight[i - 1]] + k * value[i - 1])
# dp[i][w] 取所有 dp[i - 1][w - k * weight[i - 1] + k * value[i - 1] 中最大值
dp[i][w] = max(dp[i][w], dp[i - 1][w - k * weight[i - 1]] + k * value[i - 1])

return dp[size][W]

Expand Down

AltStyle によって変換されたページ (->オリジナル) /