CT33881

Minstrel and the Starlit panels

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the honey farms of Buzzwell opens only for a perfect tally of panels. Minstrel 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 <= 1165; 1 <= a[i] <= 1000000000.

Example 1:

Input: 327 78121267 165191824 682195207 807108161 654755898 711648229 440325364 998046460 548249962 479935248 894872387 414533602 232547355 793288431 671003784 747772954 397319806 281530810 854740560 13641864 578019183 827319646 449959067 56991259 766066793 834270637 903467351 174524347 143876225 264007620 718547097 354607109 483906271 587530004 348131090 254677932 523209399 29488057 187744512 801218850 729230043 685767451 830155556 514449610 813197099 673845297 393041966 522416801 838559801 166888307 469186225 73214801 368453472 77853100 728831856 771107444 232783461 962850970 608440517 661319242 375282445 41811457 787055583 738355447 567485522 464490279 306128600 156911958 178251524 266072249 864754108 185846210 935382701 980444073 718146462 204035757 855562512 281828547 706373270 225683572 651…
Output: 8

Example 2:

Input: 762 582969780 545806800 213021638 236434133 758049762 89131228 285294989 245341867 972112055 358082118 414982053 595156851 454703630 412304082 853522455 584657763 183742404 85444966 742147044 593384800 818107155 759898598 317907369 574672224 653980257 391016766 958176519 171564253 25755767 252236715 243122793 770126905 444598206 987483687 864407648 952672841 411551819 370807189 821006838 548055663 113296664 731623824 251767169 252039143 552321491 196580984 656991239 801141488 99227859 702476641 724449892 959022175 5565242 951191033 290230465 831277878 426103281 749436040 664334409 273417830 677523548 737443891 676280665 148019614 804691709 525307798 863086657 412102458 68995043 509260061 825461402 26176284 319460982 948635420 802712796 30129237 879661705 694383220 486654588 493857458 59880…
Output: 10

Example 3:

Input: 1027 897526654 83325108 749336645 72629158 692796212 283946596 777308342 191974343 741835508 553329811 929468750 109092872 787360209 128972624 238022797 136541990 896160211 403843664 927876423 311514690 904393046 22570642 89170459 135871089 827818069 195754618 823547946 418738068 808808540 56840932 229106912 805970078 586799592 560145965 128350422 194337669 819343430 560864044 381590902 705380766 318618802 343917005 957128357 572416475 268097023 830655010 141964617 857788491 853017306 495800974 62988737 361423989 252104876 419401426 605916155 697552335 228622278 61934920 622694855 249526018 447820471 639087471 664534776 302098578 572330745 994045488 795737095 419344740 985591250 993252047 131791701 807600768 275161419 443512192 802503240 609293763 367642368 58632646 595521842 366682488 701…
Output: 13

Constraints:

1 <= n <= 1165; 1 <= a[i] <= 1000000000.

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