CT28465

Last ribbons of Porter

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Porter found an old ledger of ribbons in the ferry office attic at the shipyard of Keelwind. 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 <= 1541; 1 <= a[i] <= 1000.

Example 1:

Input: 516 720 269 613 273 771 916 709 890 809 56 22 669 192 502 372 171 718 586 826 514 715 103 587 733 816 566 690 960 541 608 412 349 277 194 560 878 849 20 296 479 375 673 675 986 902 463 131 1000 339 466 841 684 267 914 438 89 282 728 415 108 907 93 520 173 759 679 790 731 200 721 80 576 154 760 844 762 528 28 217 547 697 901 236 117 680 130 522 900 196 292 448 626 369 887 835 622 74 892 659 52 22 783 927 381 472 57 170 666 189 664 683 156 761 177 744 691 968 938 626 741 989 531 579 449 279 317 922 867 753 118 898 980 871 207 369 536 894 956 953 899 541 347 980 475 761 304 890 299 658 54 995 886 889 618 726 242 278 219 611 188 382 595 515 520 513 371 740 29 137 230 162 684 156 21 701 586 389 917 605 522 823 412 503 336 450 932 982 369 860 111 929 866 273 190 317 49 556 364 407 834 668 533 82…
Output: 10

Example 2:

Input: 842 288 831 603 156 593 326 845 830 313 291 918 142 152 326 381 78 531 962 101 846 69 865 434 654 132 45 114 465 774 48 397 537 357 100 450 69 610 148 889 970 372 663 951 222 606 924 302 957 353 573 876 225 556 840 325 11 767 556 970 981 488 862 860 339 903 173 355 967 131 826 497 733 515 263 976 529 404 494 518 945 936 33 193 981 791 138 601 606 853 563 26 457 244 430 314 975 950 963 820 100 558 123 760 642 257 957 944 499 48 709 940 692 610 916 386 303 131 549 638 424 733 253 614 246 552 331 337 767 371 455 529 670 434 977 77 330 708 519 689 287 508 197 142 167 893 332 676 39 38 138 662 829 929 788 884 589 241 539 509 451 797 539 860 440 668 789 277 828 732 365 579 405 195 481 228 80 385 199 940 208 181 793 819 993 340 595 963 216 602 249 907 483 289 302 417 849 804 720 631 629 276 475 9…
Output: 9

Example 3:

Input: 1209 718 49 928 454 347 964 844 628 884 829 886 176 866 496 18 139 796 70 629 39 173 926 91 257 328 253 957 378 688 673 755 35 230 713 138 559 220 531 525 164 168 270 782 789 15 855 644 922 501 1 773 10 813 622 97 927 698 443 439 855 73 348 318 586 330 867 513 564 855 19 474 705 35 608 975 434 620 742 809 607 477 820 406 898 45 588 254 375 585 762 721 336 826 512 142 750 612 521 794 836 636 389 798 458 651 740 685 161 414 217 189 268 560 347 532 191 337 898 592 501 570 750 769 582 563 814 217 106 93 524 463 954 81 802 194 575 126 367 220 929 424 333 882 593 75 173 361 127 301 162 890 531 443 30 881 132 472 243 592 161 321 549 554 39 330 557 986 528 295 961 533 804 763 400 985 332 791 81 468 951 69 307 272 318 869 467 207 90 457 817 800 542 728 978 581 622 71 935 486 919 877 530 260 514 958…
Output: 13

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last ribbons of Porter - EASY Coding Problem | CodeTikki