CT32477

Jatin and the Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the clockwork quarter of Gearford, Jatin records each panels in a worn leather ledger. The guild wants answers, not guesses. 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 <= 3663; 1 <= a[i] <= 1000000.

Example 1:

Input: 995 537153 34937 585306 396052 130012 745860 908180 187392 674219 756616 481302 367360 758967 76174 587012 81413 520221 375999 28292 378896 461747 884218 695459 205128 375992 235752 83976 938420 65841 92035 51071 87161 502495 84211 144486 875230 427492 7168 849472 259865 693322 916446 258630 482136 496471 875233 521659 189052 582289 988622 920750 815355 701072 259967 439263 980717 705631 832119 704133 911176 967837 210353 914254 677346 123927 651848 987859 747605 291292 364752 356619 554101 131473 680895 840172 157142 421635 723038 435564 991138 997044 832923 132238 263065 586670 340981 739092 640712 373443 883 341764 918112 127033 890772 212227 132211 673291 179962 108619 298987 129311 715510 139872 225498 133935 736044 14612 105246 857261 762326 141768 43645 247419 659603 572114 440885 1…
Output: 11

Example 2:

Input: 755 526980 144177 243937 514587 33587 251107 582339 878851 178269 86132 186267 112082 487965 406337 915618 546063 755593 628825 198736 839108 324097 306340 705804 30948 522159 167016 461885 632716 703842 921862 258975 91531 374370 203332 760600 901884 769225 872691 188734 456774 887377 745885 782639 59523 986419 452241 337881 826959 682699 883336 865000 118514 426800 317462 603206 45141 826906 285570 266828 150715 41151 461769 613460 559319 280046 349018 967702 1512 112186 497724 325187 400522 353772 76034 81586 177474 83837 574165 810454 426706 359030 729216 138571 61275 746326 506976 725215 224288 336901 859380 405934 190719 6354 851033 694604 768612 950612 832053 42365 13065 22242 785055 972124 964679 896632 162304 382374 215165 509146 391212 321649 53449 822427 481704 168098 564586 936…
Output: 10

Example 3:

Input: 2128 143232 901639 539907 482374 12163 921164 710032 396056 984590 293411 560987 124496 988591 514607 435101 982324 148199 307595 626222 221921 22041 829245 429560 205499 791151 538853 762982 479317 85773 594816 433966 662329 39185 611675 587040 247688 101523 190279 273525 379642 567738 479187 988466 401272 846172 595354 942912 535790 574454 413369 946297 372371 724331 336285 352975 456567 639851 8435 93485 413234 818166 445906 306854 565900 589943 17077 652650 91391 308114 351670 823028 930322 62674 311196 791647 724004 96829 698875 276353 319282 538767 710640 571998 690183 672834 626330 546796 620581 861654 271032 601855 745314 160688 660956 492620 101521 899042 297400 84518 769249 915324 442589 482579 428941 437327 443835 514344 223332 287817 817237 405604 628506 767857 105743 380770 53…
Output: 10

Constraints:

1 <= n <= 3663; 1 <= a[i] <= 1000000.

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