[ 0/1 Knapsack] Book example 5.10

Let y1, y2, . . ., yn be an optimal solution to KNAP(1,n,m). Then for each j, 1 < j < n,
   y1, . . ., yj   and   yj+1, . . ., yn must be optimal solutions to the problems
   KNAP(1, j, 1 <i <j   wiyi)   and   KNAP(j+1, n, m - 1 <i <j   wiyi) respectively.
This observation allows us to generalize to

Where gn(y) = 0 for all y > 0      for all the n's higher than the n we are going to, the values are 0, i.e., we do not choose them
and gn(y) = - for all y < 0      if there is no more capacity left in the sack, we make the solution so small it cannot be the chosen one