Since this weight is included its value is deducted
res = res - val [ i - 1 ] ; w = w - wt [ i - 1 ] ; } } } let val = [ 60 , 100 , 120 ] ; let wt = [ 10 , 20 , 30 ] ; let W = 50 ; let n = val . length ; printknapSack ( W , wt , val , n ) ;