Dynamic Programming Knapsack Problem Review

The simplest and most primitive knapsack problem

Suppose you have a knapsack with limited capacity and you want to load a series of items into it. Items have two properties: weight ( m ) and value ( v ). Looking to pack maximum value items without exceeding capacity limits.

Use w[i] to represent the most loaded value when the capacity is i , and the current item is the jth item . If the current item can be loaded into the backpack, then there are:

w[i]=max(w[i],w[i-m[j]]+v[j])

To be continued...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325206951&siteId=291194637