CT33477

Yami's windows Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the ferry landing of Crosswater opens only for a perfect tally of windows. Yami means to find out. 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 <= 3668; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 2252 -833869 48806 -707798 -860144 490958 -697265 6927 -924446 -306347 -527545 -163058 568117 -963467 -490570 693597 12462 -423378 -49858 915680 -930584 -9997 -7810 569791 -453788 509269 -51417 -676257 -705985 662431 -792596 349587 529015 985976 603461 483093 547066 -911363 -317969 487368 -665431 679300 449963 -892587 -245712 450012 182511 -884871 -858029 -781376 921958 512573 300973 926956 842710 983065 876177 -500239 -500577 359692 636491 -501830 -66780 468531 -160501 -326199 -90237 829225 -348927 717083 458203 -554629 325577 478847 -40271 187248 69285 -989499 -459075 -816148 794154 -822519 -89146 428014 -784482 -59621 97483 -882892 -126475 -115209 -891306 -332900 -614603 -183148 -546202 257575 491003 -24157 941361 -211905 -786909 179834 -932201 117325 510099 811597 -476006 718813 16486 …
Output: 12

Example 2:

Input: 470 178666 -629626 798105 -913571 827588 866191 -305514 -605634 -826730 640723 613365 -322189 879919 314897 150155 703095 715311 304225 114191 490264 308466 -257345 -709462 -736072 -782167 -626329 594751 429163 775726 -298659 392127 -532323 -723373 344747 -132791 -765332 -687188 429719 302598 -23134 -311649 445315 479433 -410402 -674102 -419933 -314682 657051 -186307 904763 -894267 -561774 -415912 -321674 262445 -661530 904474 -492878 561539 646824 -844801 -978313 635645 623331 675750 -77556 -830917 133074 -541620 881888 -105903 -920189 499251 -595135 746364 208455 -422722 -600263 972322 106066 502126 372315 170100 -661224 -478753 -468929 -693096 851448 -429055 752058 -949042 -438567 384372 594230 379418 514502 -554473 -935088 -759157 941202 -776837 -426514 643782 155917 -628084 632219 -85…
Output: 7

Example 3:

Input: 1427 111286 515997 825814 -806804 -328723 36008 -562511 329171 -964838 -808812 -845646 -942332 670232 -14084 683258 835567 303146 23919 -649064 -13146 -748872 -324958 -614512 -839297 -415885 302978 -922313 -955959 375718 -597065 547723 -362181 83685 835202 72673 -772451 -693484 66091 8775 -792213 634585 -910074 15496 -144690 940725 266245 353182 16684 946864 -484863 24225 -162465 114582 -553426 -580559 307445 -368316 911815 -805449 -81098 322646 561615 324953 -792255 132003 -617037 305805 -302036 -712043 101456 273664 -48832 910777 88609 -731171 -133135 363321 -989915 -304414 -873667 402914 -722045 -232508 842823 615596 229501 -108724 189122 465580 -931432 -196346 -369937 737122 901652 779788 826688 -381688 -569712 591109 -455058 309542 663194 -647763 -179195 902289 -64204 -304631 -48563 2…
Output: 10

Constraints:

1 <= n <= 3668; -1000000 <= a[i] <= 1000000.

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