if after maximizing the ranges any 1 is left then we maximize the string lexicographically .
if ( cc > 0 ) : NEW_LINE INDENT for i in range ( len ( s ) ) : NEW_LINE INDENT if ( zz [ i ] == 0 ) : NEW_LINE INDENT zz [ i ] = 1 NEW_LINE cc -= 1 NEW_LINE DEDENT if ( cc == 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT print ( * zz , sep = " " ) NEW_LINE