If no solution , select from previous k - 1 packages
if ( dp [ i , j , k ] == - 1 || ( dp [ i , j , k - 1 ] != - 1 && dp [ i , j , k ] > dp [ i , j , k - 1 ] ) ) dp [ i , j , k ] = dp [ i , j , k - 1 ] ; } } }