CT25777

The ribbons at Highreach

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Kavya found an old ledger of ribbons in the observatory attic at the mountain city of Highreach. 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 <= 1218; 0 <= a[i] <= 1000000.

Example 1:

Input: 907 797032 332733 204147 465969 880033 112699 680305 39088 843713 83823 124195 75213 391381 637196 411194 337001 131798 44287 930986 169998 26691 733793 437733 182960 612384 819464 284683 717690 812229 34975 106007 806169 819706 37287 642200 916322 749861 143350 531685 84139 444305 615006 239505 132881 723878 627408 786063 831091 585661 878977 20473 268768 767839 406898 922301 341699 443448 73762 63260 348481 202721 296170 791063 703441 505220 361862 257521 144487 256995 389238 94651 472198 333699 105334 767232 881280 3007 955899 790551 782917 781739 657789 812765 625126 131869 626119 931253 412025 32367 410496 360710 631397 293430 712615 341837 548233 215076 471889 435830 565794 488053 369814 659305 201139 985457 502555 888035 468796 379723 525343 599808 988216 28754 956657 975620 25670 1…
Output: 10

Example 2:

Input: 1003 386155 893292 305400 931825 756911 648435 943304 556407 525687 53623 964729 411303 658309 713999 299698 771635 712284 199245 856493 252839 954506 231088 64921 548866 956132 913169 252044 631494 66124 248838 708331 40238 77079 453747 216302 504915 658504 89703 104931 964618 569809 64952 776336 965318 104640 575763 810364 728382 371833 731410 690401 942351 246030 555106 930470 239325 558372 76666 408015 318327 507151 582200 364252 340409 425512 822704 485802 283848 795799 266176 289216 45762 592423 549696 506726 636761 626170 279677 206301 22783 261511 901045 517522 602156 25566 629812 533464 897327 962274 836386 736763 525996 114832 892957 62361 333880 883315 297596 454252 409755 821565 85794 303490 284982 270343 962878 292414 37178 681451 727361 23862 278712 608423 653211 173135 60868…
Output: 10

Example 3:

Input: 131 250709 25289 703048 162632 500213 991537 397722 622132 332408 387426 53036 778607 990323 540183 714276 441265 622148 807124 48894 325572 192197 348177 25456 46380 386419 846709 466323 478853 918178 296695 717075 40102 662320 74373 762138 906744 933743 930337 549755 60947 762034 328061 583861 17778 446795 619180 1475 176234 944857 530905 24695 904398 663909 117165 668797 611701 517230 785738 30262 818992 123434 196772 537552 172643 822932 196799 173203 442047 634292 66504 375024 240689 227123 541195 704685 745237 34623 507566 85646 951439 183293 863414 381465 207195 190805 400196 125043 174590 414938 632588 705736 774191 220945 211768 187769 386305 307794 937280 109686 240179 329352 194141 225122 741257 836376 959406 796572 821217 860207 997333 882062 554354 526011 774689 765698 851262 …
Output: 7

Constraints:

1 <= n <= 1218; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The ribbons at Highreach - EASY Coding Problem | CodeTikki