If this arrangement is not possible then don 't calculate further
if ( temp != 10 ** 9 ) : NEW_LINE INDENT ans = min ( ans , temp + ( ones * zeroes ) ) NEW_LINE DEDENT dp [ start ] [ bucket ] = ans NEW_LINE return ans NEW_LINE