算法笔记/USACO Guide GOLD金组DP 2. Knapsack to DP

今天学习背包DP(Knapsack DP) 

是USACO Guide的DP章节中第二点


教程

Knapsack problems generally involve filling a limited container with a subset of items where we want to count or optimize some quantity associated with the items. Almost every time, you can think of each item as having a positive weight, and the total weight of the items we choose must not exceed the capacity of the container, which is some number. Some variations of knapsack-type problems include:

背包问题通常涉及用一部分物品填充有限的容器,我们想要计算或优化与物品相关的一些数量。几乎每次,你都可以认为每件物品都有一个正重量,而我们选择的物品的总重量不得超过容器的容量,即某个数字。背包问题的一些类型包括:

  • The 0/1 Knapsack problem: Choosing a subset of items such that we maximize their total value and their total weight does not exceed the capacity of the container

  • 01背包问题:在一堆物品中选取子集并且使它们的总价值最大化,并且它们的总重量不超过背包的容量

  • Finding all the possible total weights that we can achieve from any subset of items such that their total weight does not exceed the capacity of the container (in the chapter of CPH linked above)

  • Counting how many sequences of items will fill the container completely, meaning the total weight is exactly the capacity of the container (the order may or may not matter)

The DP solution to knapsack problems usually has the state keeping track of the capacity of the knapsack, and the transitions involve trying to add an item to the knapsack. In competitive programming, you can expect that classical knapsack problems will be given twists, disguises, and extra state information involved.

你可能感兴趣的:(算法,算法,c++,经验分享,学习)