CT34350

Scribe's Ledger of stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the ferry landing of Crosswater close for winter, Scribe must finish the stretches ledger - one figure at a time. Task: Print the length of the longest contiguous run in which elements alternate even, odd, even, odd, ... Input format: First line: n. Second line: n integers. Output format: Print the maximum parity-alternating run length. Constraints: 1 <= n <= 1553; 0 <= a[i] <= 1000000.

Example 1:

Input: 1202 13247 285549 236983 787312 538663 845462 983399 316415 725581 460771 866664 311095 78289 263362 424237 449364 39053 995539 32975 670669 300864 203123 271464 119767 377797 275518 76130 652924 394489 251958 504173 181884 104542 557097 754864 156955 904630 548082 336236 551286 565419 334085 424207 87565 621956 283785 423401 825685 884479 45568 57489 979385 261812 464022 538063 502040 513289 133567 260152 996581 152652 22150 851633 393955 263021 173160 559364 881174 288587 715168 701873 221346 57741 296834 425598 904986 937252 862524 727824 383631 525425 996002 223728 470393 395315 322979 756583 409415 601307 110429 912872 698200 781910 733756 704553 482072 991514 180089 257778 65292 400626 321573 87550 384841 67435 786906 219493 966657 67674 86680 302008 85926 373162 392494 859181 321948…
Output: 11

Example 2:

Input: 410 424679 938997 142460 452164 892542 186303 646345 657095 529236 760316 442659 837894 982066 5614 101335 129935 986387 25242 615355 679301 523774 737750 238483 778820 232253 814435 877119 66803 642783 751272 634789 933831 372661 998354 496319 184687 771043 594661 610848 817517 959566 512442 712466 349185 836703 958039 830705 313914 564640 598245 174483 130705 385969 715111 520006 909812 79887 634910 778120 226426 355696 270693 209017 779406 944394 714887 393185 886014 76076 26336 499872 920676 625712 835444 387124 447513 136621 813157 402163 192266 14352 414868 318852 770794 811157 482178 161445 732059 323670 313148 882508 868479 485918 731038 853184 40149 202978 223693 751685 854483 935080 531141 831906 410514 280568 984107 712050 579904 830358 321891 827223 317934 872228 245302 780441 …
Output: 7

Example 3:

Input: 598 244468 256150 354760 721325 964652 356260 370833 745090 157700 614316 790049 326029 447494 368932 864322 524760 794181 199651 224008 449474 880845 318881 905714 282043 879216 564180 548957 343684 710962 42546 493633 910481 885299 504607 322213 849862 174523 721015 35876 944281 835571 438183 348551 333846 586036 740121 76553 728162 753010 571314 206359 703862 913840 832496 188630 423537 767020 135898 992365 65064 38599 497 312515 811105 424384 740308 996454 608002 207622 802529 976118 657533 657209 624806 273801 789372 962888 292236 766511 668467 49601 179272 708001 90416 756086 751560 91378 512994 325314 331380 236341 133859 812408 630603 444009 939247 960745 296663 360771 330006 30035 740936 314638 41873 799541 414398 320641 320541 79065 873784 828884 786228 968192 42590 430681 191497…
Output: 8

Constraints:

1 <= n <= 1553; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Scribe's Ledger of stretches - MEDIUM Coding Problem | CodeTikki