CT34689

Theo's Ledger of weights

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Theo the chronicler watches over the spice bazaar of Saffronia's stores of weights. A careful computation stands between order and chaos. 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 <= 7222; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 1346 -249051 -130335 -172216 629784 -22786 105455 976964 -392111 -382396 746285 143878 179592 -738820 631416 616178 850628 440349 767001 -472623 245956 458289 230143 688773 271937 846211 -991901 -781590 -100400 -832236 539873 -582761 -120801 722016 872255 -286308 -79214 -774495 -833321 742029 958863 -854790 720998 -860864 563094 -372991 744174 371496 601012 -866787 473321 190204 776065 844917 197154 -470281 829572 352653 916261 591140 -507909 -101179 -710824 -993477 658394 -626375 -484660 -604811 415013 -124114 594252 99011 398259 -113723 -106211 -886727 -902018 -33079 697780 -385333 -966826 -231746 -330540 529699 240752 -521756 -448731 374733 427884 -577851 305077 675628 853427 -39363 716089 -861630 707530 757974 388435 915668 108838 -985872 224026 -339699 3005 -976394 184007 37278 340858…
Output: 2

Example 2:

Input: 5235 678324 754045 797683 593396 728245 -497383 -126805 917508 438236 995248 -244880 479487 -494326 873728 -574527 -714391 348847 -671983 -800848 441180 835449 416674 720417 -736024 -459096 -569483 -912770 -565907 862746 802076 640856 -607767 351859 789639 -706973 235268 -505944 -690435 -554273 -876171 206422 -161077 -113022 111074 -669060 729298 -85727 832719 -75664 -314139 -21288 -821749 847940 874330 618933 -783725 926231 316985 471855 -551921 312249 976725 -571875 -160459 630951 -894646 243911 941412 -184324 -728647 61983 -463618 584806 566664 662523 -153180 -311383 466002 340428 -917396 -209898 -735705 -831429 -235659 836578 670635 318274 105530 941038 494293 -868105 -47372 419103 -655959 382772 193066 19828 570216 -315643 861745 23569 402761 -457368 245717 -806747 -251099 -635945 561…
Output: 2

Example 3:

Input: 2062 -876019 271092 -673798 -452039 580435 66908 -62567 825705 -159547 870179 362710 234102 -848326 652895 108538 903406 -228838 -292667 389834 -66701 -136490 703494 788699 598298 870116 -886420 734519 -734581 188770 -100095 417167 -228457 -729735 -879696 596862 942205 -379462 -721892 117021 -170724 -605183 83187 -113624 -715771 -843077 711330 545278 371413 182214 929472 903329 577299 533095 197939 714961 835618 323139 692264 643331 573820 847139 350416 394348 32555 811957 474824 268158 -677959 -275810 269130 -262605 -417619 581800 -748141 -67186 726572 691615 -808802 387372 -217384 194281 -546059 19728 -351677 918104 678532 182548 908935 -194921 -870281 692489 23825 124996 -606608 430582 546305 430703 254934 -42525 -769319 868799 264813 458631 579603 -34585 -55327 -103244 -38119 321437 -3…
Output: 2

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.