CT33697

Viktor's Checker Stretch Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The inventory keeper Viktor has been asked to tally the donation drive. On the desk lies a long table of ribbons readings. 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 <= 1451; 1 <= a[i] <= 1000.

Example 1:

Input: 314 821 767 300 162 41 881 986 769 192 32 360 993 587 123 478 540 456 922 594 487 536 382 426 666 624 137 182 657 654 160 807 9 204 938 901 193 724 938 69 931 895 512 363 335 166 446 787 118 409 806 267 206 225 460 109 147 833 651 845 330 242 826 153 834 255 585 341 976 912 872 214 353 529 153 246 368 752 835 702 396 988 537 350 713 588 902 39 559 90 564 91 713 717 316 328 444 561 584 387 36 45 927 642 791 448 463 7 84 687 680 86 381 159 692 775 451 353 84 109 34 805 310 510 840 993 227 275 288 420 154 53 64 568 130 374 751 166 690 750 847 916 444 740 943 554 144 829 937 392 704 797 701 945 525 621 429 913 448 644 9 819 165 769 199 682 662 557 742 417 824 444 677 872 726 881 358 903 43 276 981 238 617 219 33 176 126 577 120 368 193 550 613 65 174 616 682 137 47 990 312 104 898 95 164 796 3…
Output: 10

Example 2:

Input: 1265 515 362 317 616 849 483 42 836 610 121 418 389 499 853 141 762 182 160 883 316 918 838 317 945 622 219 870 134 972 536 950 28 435 716 852 918 525 952 912 187 861 868 219 79 261 261 322 475 816 108 235 654 278 799 696 927 899 896 155 481 930 152 296 799 766 514 930 819 243 471 344 672 35 260 706 991 928 465 899 726 189 156 961 285 689 453 515 111 54 343 347 628 84 708 939 641 289 77 421 635 4 487 939 586 146 784 915 211 209 32 245 515 507 778 852 777 908 54 79 418 27 427 243 767 82 538 500 260 597 779 639 798 626 124 560 420 888 996 789 114 578 795 174 644 991 635 532 79 854 111 805 152 182 187 608 764 978 252 632 689 652 864 866 125 251 25 770 458 751 759 293 231 596 218 194 318 719 972 769 72 705 336 868 189 935 738 796 125 114 731 582 255 925 402 674 437 410 69 571 123 596 517 771 3…
Output: 10

Example 3:

Input: 1356 637 828 852 932 870 880 70 586 637 670 363 207 210 933 866 567 358 693 517 154 874 147 504 949 775 329 343 479 547 287 647 224 807 444 861 406 8 524 559 777 273 893 757 223 510 469 635 35 658 811 662 387 863 675 558 189 159 758 805 526 419 232 354 738 723 800 546 180 936 835 398 985 423 178 706 784 49 743 157 914 96 523 305 843 305 711 855 27 971 121 140 725 49 586 814 414 327 294 635 866 771 179 26 552 199 231 941 814 495 768 305 896 312 526 122 95 759 167 592 483 681 306 960 102 583 113 663 980 517 235 737 212 127 864 821 857 891 724 6 125 498 99 947 27 63 177 622 995 809 421 681 280 871 272 570 29 609 912 672 958 237 15 973 82 563 54 584 146 458 567 344 390 258 117 72 422 633 18 378 516 512 430 589 209 425 584 985 393 655 428 545 654 844 127 552 973 653 795 38 227 715 88 932 720 45…
Output: 10

Constraints:

1 <= n <= 1451; 1 <= a[i] <= 1000.

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