CT30711

The Indigo Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Jaya found an old ledger of ribbons in the exchange attic at the old quarter of Brasshaven. The margin notes pose a precise question. 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 <= 3552; 0 <= a[i] <= 1000.

Example 1:

Input: 1004 35 350 239 95 267 356 645 283 87 474 863 743 918 94 609 604 603 489 872 563 187 234 376 111 252 853 37 139 778 295 570 979 429 919 423 888 142 595 819 879 799 12 2 15 640 247 487 221 812 486 321 113 837 555 361 393 161 651 333 751 759 59 679 817 46 895 158 482 119 661 849 840 786 754 522 977 245 491 72 481 214 693 206 440 613 690 241 292 78 114 450 592 247 435 326 396 287 433 381 966 427 351 982 389 411 224 284 146 627 478 248 175 795 993 889 79 23 114 670 863 303 733 799 712 120 251 726 125 236 100 801 197 862 360 583 111 927 516 0 867 684 991 404 283 105 228 398 707 524 935 17 979 806 722 382 536 937 294 619 74 642 620 315 969 74 392 581 269 584 160 19 281 665 924 171 560 516 731 888 673 26 61 9 465 433 543 572 563 170 133 321 180 868 125 874 620 670 26 607 250 479 799 21 953 701 37…
Output: 9

Example 2:

Input: 1380 838 254 887 447 492 104 793 309 677 2 927 37 830 430 63 985 91 387 418 395 621 640 301 679 788 982 234 81 572 291 274 824 723 971 197 782 238 493 994 27 189 645 509 970 435 567 2 247 204 933 333 695 979 939 50 743 161 600 557 589 273 963 633 195 933 997 381 303 255 624 293 199 833 965 264 739 449 766 121 279 320 573 886 548 23 279 75 570 500 903 433 649 574 270 533 413 450 985 221 282 965 977 239 62 58 938 172 862 494 177 249 861 555 361 442 840 850 735 439 922 726 725 476 903 703 360 264 610 269 76 376 529 573 453 335 477 801 987 837 150 882 321 319 589 619 119 891 523 622 843 805 98 111 782 96 122 143 627 785 418 635 278 852 374 665 816 667 15 733 189 150 403 450 184 432 805 901 531 170 776 308 64 432 642 956 103 665 307 70 378 625 585 106 641 2 185 631 257 32 396 673 332 642 443 82…
Output: 10

Example 3:

Input: 441 808 694 284 237 889 485 756 214 597 917 744 482 800 228 309 232 992 311 986 524 680 738 103 120 949 802 529 522 819 331 488 636 329 275 44 81 610 626 891 790 954 921 898 460 823 295 799 815 523 178 345 712 652 635 289 791 75 938 63 339 252 352 762 407 273 557 149 449 111 501 37 627 271 893 63 386 344 403 750 764 234 141 800 543 678 813 655 115 199 522 135 762 90 920 871 522 664 11 315 709 535 485 635 921 125 480 297 49 271 721 303 643 270 275 400 232 509 163 303 304 78 927 481 171 925 207 180 881 29 678 361 850 753 648 857 913 87 574 646 14 91 122 547 482 413 581 665 906 818 66 651 867 505 505 404 108 911 497 344 685 759 70 818 362 243 316 979 208 373 706 521 846 765 822 146 763 973 88 878 247 547 805 864 544 6 630 63 395 628 834 960 263 803 359 726 551 917 560 171 681 247 751 378 151 …
Output: 11

Constraints:

1 <= n <= 3552; 0 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
The Indigo Checker Stretch - MEDIUM Coding Problem | CodeTikki