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...