CT31639

Last shelves of Iris

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Iris runs the granary at the obsidian flows of Blackglass. Today the books show a list of shelves, and the numbers must be worked out before sundown. Task: Print the length of the longest run of consecutive integers present in the array (e.g. 4,5,6 counts as 3). Input format: First line: n. Second line: n integers. Output format: Print the longest consecutive run length. Constraints: 1 <= n <= 6703; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 633 597177 -678306 -575017 -865531 -434468 -200532 269473 441134 235129 776864 264058 788196 29773 -835018 -315068 -541066 161386 -727884 -359177 -123600 -264274 -186874 -561126 830411 -230875 -81512 194690 -98730 136083 -723111 -92741 -839472 776358 970015 741948 902397 -693347 -488690 92758 542282 318254 51285 -344848 -206718 -740936 305937 -403963 -940926 199866 -57179 783039 613778 702819 -683386 -312803 -796934 -675255 -693625 254041 -823526 -535456 -890305 446160 983608 600844 -985715 811309 -196734 252104 -956221 922894 436481 -165987 852839 395425 838639 603681 -240316 224597 420316 -227698 683596 505619 294095 -735016 -417590 -21056 -820117 34818 913041 -127059 -764411 639099 678060 255028 -961049 986980 -473103 96080 -966898 509940 -645582 -243600 -736809 327154 948448 643017 -56…
Output: 1

Example 2:

Input: 3336 367377 612174 371685 -61466 416118 -308116 -766425 -867923 -155737 -155312 -248244 -182342 372833 435283 397163 845451 218971 691726 682831 209633 -727651 -723232 101268 831190 556162 411861 741556 -541827 -946429 -118517 -226852 305872 871477 -372333 -918461 -359783 -526792 -7579 290556 -39674 -197304 -255374 853243 742613 100085 -799793 -424374 -677044 -410163 -709586 -909636 841989 -868227 -161548 -616699 -475552 -31131 -526068 583621 594900 666295 605562 184303 336615 47538 -769724 283415 762915 124061 -467720 230935 -516939 200454 640622 -415442 -760726 -792673 -376906 721782 550790 729075 -798943 137130 -305552 473242 784700 129918 -482360 698362 199567 -177236 -990664 -740400 373016 585842 772524 -205435 -409316 322081 -655625 -811814 637212 -569430 -948989 -778212 128444 -4258…
Output: 2

Example 3:

Input: 4764 843319 583989 486426 955211 217524 -253868 550086 526721 494778 -826733 716847 -177607 -23513 637590 -918835 -705127 -680896 -951060 -410690 857350 -787462 -943380 535031 -768369 -908549 106435 -84165 -614882 -724407 763410 393025 312253 -354541 41866 936497 -64381 -3154 -111949 -832428 -298501 -822607 -77558 -545808 133928 -80833 427683 797976 -99501 420033 -75131 -518452 -29966 909639 -768225 704486 410894 343162 -321274 737140 33513 -598659 420939 -852410 -270703 555711 414818 -879176 212743 494402 853476 672116 -999682 497411 965407 392317 71050 634718 -595251 238048 -62338 -388080 782016 568231 135203 -544845 866143 2391 161435 -795428 181778 -871682 -65923 808635 844853 18999 223787 -638432 465211 -639959 680717 672311 556692 -865721 -893643 -856935 985990 944875 323387 -606101 …
Output: 2

Constraints:

1 <= n <= 6703; -1000000 <= a[i],x <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Last shelves of Iris - MEDIUM Coding Problem | CodeTikki