CT29397

The Checker Stretch of the Bright ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Emeric inherited the cooperage at the tulip beds of Bloomhaven along with its curious bookkeeping system for ribbons. Time to make sense of it. 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 <= 3794; 1 <= a[i] <= 1000000.

Example 1:

Input: 1325 590272 545423 818988 200717 347024 838778 299929 992251 818513 324884 268672 701890 237661 220248 894214 131171 397872 739236 286932 715624 86098 819203 993556 74188 413412 159338 348509 283345 7448 196126 754256 134678 896417 685552 110207 929940 166547 563508 847258 353679 787263 506899 77589 666330 310638 576047 718557 795061 410846 204668 968445 572161 368432 694532 896806 842870 328282 720905 802306 271948 945284 573074 266537 594932 754939 546488 519042 658844 431520 202263 28635 944827 976962 179942 158323 250433 710189 125787 814149 930746 829076 142437 469656 743059 990773 291335 247805 38826 927388 553884 127937 669725 556612 920075 803070 172846 490781 418301 160053 891470 703101 888408 371447 816529 159297 36122 614518 166573 953951 556675 438050 365790 321437 441472 71832…
Output: 9

Example 2:

Input: 3111 251472 277851 780664 114469 505928 407293 976975 968400 87028 337913 147779 898284 7592 752541 447359 527733 881744 591964 802545 329952 181534 8790 207985 622274 246190 215826 374847 9516 98257 574156 799336 676297 389535 888466 244655 511160 279672 499095 823279 697067 554196 582468 357777 66132 352947 955421 719294 461616 488086 793974 492034 620930 30649 227200 16491 827153 862120 714320 804397 960754 730381 759964 949696 322221 429905 207366 672808 160437 71977 686432 242236 996263 486021 571055 362642 720921 822395 893957 366996 576659 244403 510046 975434 724194 865069 844792 29786 937937 268819 413512 269150 484122 589225 235355 289421 886312 56090 661235 125776 517588 363721 790721 358670 427436 57134 934705 215381 347906 677126 767566 930388 737961 170504 115293 212763 51793…
Output: 10

Example 3:

Input: 2351 205285 606476 337508 458572 235373 289790 518764 330643 57039 490045 402542 763258 111050 980914 902708 12790 409981 543416 278918 381663 615995 829513 66831 170295 619593 546848 885254 635168 734488 757619 991542 357987 220936 427445 765946 474858 728681 464853 131479 378415 137455 933119 104020 889146 728911 650667 709234 962265 698131 322456 697706 641103 38937 575054 377551 884417 909985 417005 333277 234959 392533 943601 731540 363545 530575 572815 808980 930915 209186 369247 83534 609493 73530 39841 705568 865580 787076 672408 545374 859869 235951 244133 873444 737771 102048 632214 245202 812252 806746 926590 250968 635167 493203 676265 622662 611830 651455 955155 638436 969762 477531 370530 805493 795067 233128 220237 67113 324388 132986 96091 223466 606241 327637 107107 771575…
Output: 12

Constraints:

1 <= n <= 3794; 1 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The Checker Stretch of the Bright ribbons - MEDIUM Coding Problem | CodeTikki