there n pearl row Lets enumerate integer 1 n leave right the pearl number type ailet sequence consecutive pearl segment Lets segment good contain pearl typesplit row pearl maximal number good segment note pearl appear exactly segment partitionAs inputoutput reach huge size recommend use fast inputoutput method example prefer use scanfprintf instead cincout c prefer use bufferedreaderprintwrit instead ScannerSystemout Java