CT31961

The scrolls at Bloomhaven

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the tulip beds of Bloomhaven as Vani unrolls the day's manifest of scrolls. 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 <= 3790; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1033 205219399 191732138 397226382 596680942 690682305 469443984 182845218 605345770 280811720 478842131 149309840 389695269 227778515 744338490 656232065 772360791 961269432 618713662 327936117 273109277 766152083 266088611 236684439 490589974 650035167 500262925 336624838 223177477 761362170 356719476 484291882 317857230 454127807 608651067 762197154 189871106 439884610 304753669 458637994 276954796 128322986 121692123 715506770 754983395 895781062 774340657 508378800 699596404 234185245 780411741 64076267 766942188 337708383 865235739 127030023 103066330 644389557 580951055 691175055 113777146 100569528 965856257 924573455 57596935 711372251 758993228 630802343 498809977 864338749 412432193 574750037 146824253 -442636 550469602 653588875 521910732 809078175 414746222 715144970 987710130…
Output: 11

Example 2:

Input: 2840 64684222 318558948 347728144 106853706 189726767 175481747 97265822 172203331 624380880 541719579 986774866 597803924 794507161 822004499 695156864 294844470 732494626 323335356 972292459 952010679 417631406 79737421 298713608 573000451 566602090 42552311 227372739 360979835 17383707 549528282 683436025 144185375 38919848 82200435 134643099 441244691 779279842 394100685 517312075 247078083 742706076 503070439 556987729 330462436 698254163 904060833 734206618 743849398 702028787 484622243 521067339 789568817 447356234 778439337 587609647 52103156 752199006 226247493 122397935 723386538 349569555 120847615 779084054 271696826 212021675 8124734 785227511 10188095 640850509 862500771 698016831 543247827 939925632 113907450 581188766 763232889 508557241 248593598 208752795 83195228 4531915…
Output: 11

Example 3:

Input: 741 91337176 158682549 467110887 550301089 780764728 760650497 611380584 558823010 140831229 501916624 501130363 287772540 465928721 115063036 393531009 483278601 398331067 695756041 65746270 242349763 663630077 664262191 875320317 524638972 249813301 443459334 29082158 703383446 519904402 772845967 198389283 170462396 261040744 98202553 13868328 688231881 557055264 551097356 252851104 937142694 112111045 986074411 865820616 332993559 489514729 143663320 290652133 164112932 502069625 822673448 450672165 968907711 338439784 196303737 366528243 736832467 70561313 636872924 564455409 104202384 720749351 537984407 582037920 57631247 91665950 740673891 554370929 775426348 480646574 934886395 359494389 536663479 233903121 959349139 297355311 681028616 969193465 214708880 180568428 167852181 6295…
Output: 9

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The scrolls at Bloomhaven - MEDIUM Coding Problem | CodeTikki