CT29487

Marek's Celestial Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the indigo vats of Bluehollow as Marek unrolls the day's manifest of stretches. The tally will decide the next shipment. 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 <= 3374; 0 <= a[i] <= 1000.

Example 1:

Input: 2122 668 59 27 763 32 860 761 445 243 565 483 184 195 864 141 35 386 55 154 260 3 140 629 679 365 513 213 9 443 450 724 37 942 877 852 677 143 659 632 182 745 718 323 9 793 508 382 348 18 99 115 790 923 449 116 433 789 84 234 210 495 553 688 893 344 757 584 526 959 125 656 861 582 58 454 77 538 779 887 358 515 7 754 475 762 742 772 250 436 69 316 354 544 984 215 316 236 601 531 594 433 712 21 521 186 948 527 565 359 10 339 757 176 164 930 517 21 881 968 805 890 798 516 36 114 642 28 853 824 193 587 14 880 136 382 347 370 100 392 574 906 645 527 981 593 95 212 413 645 706 941 813 422 114 51 836 144 325 739 34 642 988 315 456 194 274 367 142 77 825 752 939 222 654 272 295 44 485 286 71 51 529 708 928 628 126 550 926 779 33 483 925 813 635 284 844 625 617 165 707 432 969 502 706 734 853 331 6…
Output: 12

Example 2:

Input: 2879 453 883 416 740 75 703 628 788 434 900 896 383 182 344 808 867 426 374 331 506 811 503 592 232 697 780 453 673 79 863 994 592 978 496 475 434 479 210 455 350 256 616 330 414 674 611 893 984 272 685 307 58 394 301 375 54 665 426 357 645 309 9 545 22 569 332 142 168 733 286 586 605 610 471 77 215 851 292 22 724 831 276 34 516 456 732 278 159 598 975 539 115 599 949 177 81 155 511 13 535 203 191 466 108 61 317 122 120 250 692 23 419 864 144 885 778 58 763 636 509 173 158 505 164 864 318 651 722 558 933 721 597 573 96 313 811 641 766 226 983 686 536 758 192 572 620 913 62 376 933 756 1000 711 732 145 254 834 868 993 453 515 692 264 891 187 296 374 694 959 316 893 48 81 392 769 59 816 684 532 277 449 31 854 867 627 85 275 279 284 791 180 136 264 66 157 392 368 191 443 131 253 480 663 201 5…
Output: 11

Example 3:

Input: 1880 766 851 71 477 542 187 640 913 407 227 712 725 701 156 50 953 346 930 42 794 170 402 404 689 890 28 0 44 818 736 895 644 240 835 484 228 240 304 902 892 22 661 209 43 264 67 234 869 989 414 172 385 134 641 238 443 694 991 39 556 186 61 493 599 602 610 243 78 293 769 114 804 598 458 90 116 95 892 799 787 53 413 53 890 505 972 893 302 628 417 649 468 356 392 403 902 842 812 594 774 851 883 429 397 893 923 296 978 481 11 288 16 195 243 633 697 83 820 17 710 959 101 525 671 14 267 81 890 272 382 754 204 430 584 673 344 492 745 133 831 110 281 255 108 962 846 49 130 307 340 520 838 765 378 376 644 288 582 782 224 552 451 269 174 55 658 158 914 658 299 730 568 533 556 350 866 948 656 405 165 313 125 218 790 33 843 768 215 193 468 603 271 990 451 783 555 914 950 97 582 901 471 685 893 503 21…
Output: 19

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Marek's Celestial Ledger - MEDIUM Coding Problem | CodeTikki