If no solution , select from previous k - 1 packages
if ( dp [ i ] [ j ] [ k ] == - 1 or ( dp [ i ] [ j ] [ k - 1 ] != - 1 and dp [ i ] [ j ] [ k ] > dp [ i ] [ j ] [ k - 1 ] ) ) : NEW_LINE INDENT dp [ i ] [ j ] [ k ] = dp [ i ] [ j ] [ k - 1 ] NEW_LINE DEDENT