11 backpacks
Last updated
Was this helpful?
Last updated
Was this helpful?
这里有6个背包问题,方法主要是把值作为其中一维,把能选的元素作为另外一位(前i个元素)。根据能不能重复取元素dp公式会有变化.
Note: bounded backpack 1 dim optimization inner loop need to pick item from back. Unbounded inner loop can pick from beginning.
Other Related:
- IV
-- 听说还能bfs,两年后回刷,还真能bfs;然后数学解法是四平方定理,然后还能递归,还有另一种DP解法。太高级,有空再补
求方案数 - IV
求方案数 - V
-- backpack VI
416 Partition Equal Subset Sum