CT32447

Qadir's Ledger of windows

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Qadir the dispatch writer watches over the valley of Misthollow's stores of windows. A careful computation stands between order and chaos. 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 <= 3204; 1 <= a[i] <= 1000.

Example 1:

Input: 2002 451 614 429 251 623 672 219 492 535 960 265 393 159 658 679 930 534 935 857 916 82 400 849 41 656 81 342 813 148 120 862 293 607 906 24 875 827 186 949 564 58 745 706 383 901 737 993 593 65 922 271 459 168 496 451 771 538 182 180 989 275 582 805 402 445 141 756 997 604 609 726 686 37 924 7 472 972 114 216 851 939 867 981 982 571 110 11 742 977 895 759 897 546 968 769 425 557 220 78 769 420 937 324 203 716 881 658 604 198 306 270 610 717 555 330 850 722 635 110 251 752 28 300 609 64 200 152 613 403 757 750 228 73 197 281 839 934 624 368 575 411 716 92 560 979 893 580 723 651 765 686 791 132 80 637 58 814 701 74 407 30 617 928 785 360 794 760 898 562 823 365 908 393 483 569 149 701 289 810 71 341 679 11 19 909 142 795 702 820 485 91 390 377 703 162 804 873 821 814 993 545 156 677 536 52…
Output: 9

Example 2:

Input: 2654 104 101 110 962 193 52 170 74 679 765 365 642 641 998 560 537 449 561 141 779 808 743 362 491 605 754 150 724 886 583 371 591 960 282 760 24 596 881 946 929 87 356 400 94 503 183 613 977 56 346 760 538 895 769 416 977 521 409 981 485 894 735 826 164 878 73 184 155 819 571 991 445 61 689 531 343 777 210 537 12 846 473 46 218 168 313 368 975 354 436 563 722 141 843 868 56 161 887 422 565 380 14 688 149 706 188 302 732 17 535 475 201 560 665 676 713 382 804 753 233 850 991 120 628 941 907 11 161 812 416 182 226 543 906 39 319 174 263 518 774 902 307 707 620 75 424 515 522 851 576 378 156 586 179 439 57 73 374 868 448 182 430 884 973 402 784 660 995 514 925 155 128 568 236 956 508 217 263 81 263 896 485 796 534 272 904 159 6 825 920 170 469 623 54 742 636 36 14 25 390 983 257 576 823 683 …
Output: 15

Example 3:

Input: 2909 756 462 975 195 366 910 980 495 588 630 185 241 52 527 893 981 282 350 645 754 761 106 265 114 174 368 65 199 434 980 236 95 607 811 144 264 757 372 161 247 308 787 903 310 151 361 420 712 401 155 948 105 206 157 490 852 4 72 638 319 348 840 870 522 701 769 769 773 213 169 484 647 245 680 61 377 226 442 675 820 262 748 127 277 522 614 620 33 772 587 587 882 342 663 984 181 996 630 56 76 80 929 2 351 977 211 432 141 847 301 826 922 669 261 947 942 321 470 707 873 211 226 982 191 416 276 627 782 59 256 676 474 803 660 819 427 547 880 281 640 110 609 995 960 50 638 116 119 203 67 102 989 896 202 539 76 714 410 17 5 766 741 946 632 972 588 793 233 870 864 887 548 550 434 552 923 801 707 206 955 358 996 645 753 509 488 696 812 250 185 748 847 743 120 852 835 377 137 507 764 334 596 771 351…
Output: 13

Constraints:

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

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