If k = 0 then this arrangement is not possible
temp = 0 NEW_LINE if ( k - 1 >= 0 ) : NEW_LINE INDENT temp = ones * zeroes + dp [ s - 1 ] [ k - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT temp = sys . maxsize NEW_LINE DEDENT dp [ s ] [ i ] = min ( dp [ s ] [ i ] , temp ) NEW_LINE