CT33639

The Hidden ribbons of Kian

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the silver mines of Lodebarrow, Kian the paymaster keeps careful count of the ribbons. Schedule the next expedition, every figure matters. 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 <= 3882; 1 <= a[i] <= 1000000.

Example 1:

Input: 3157 713199 316544 948933 936385 655566 22363 937330 191226 421227 518728 691408 981263 322572 10109 891626 247844 583418 893751 213322 358209 416603 201743 512491 300712 775650 751105 965799 296317 633311 63117 486033 37558 933487 751512 543100 408646 637418 687413 146069 227805 319352 806655 756626 64989 279404 433096 877773 436224 609536 93274 383424 264444 178167 285019 8678 670246 691451 196149 716450 360728 951969 639360 653581 941306 109863 178816 890059 208584 439811 950716 629045 72482 319726 737097 564006 400332 391722 563087 412574 215983 368336 741882 590687 644211 590789 568865 561521 958220 259765 225474 329299 780775 302346 388750 328423 249163 619043 915315 975128 423488 921292 181302 222231 120672 991423 499416 916548 7968 953664 549741 955329 348025 229986 758341 471192 2…
Output: 15

Example 2:

Input: 3472 262253 750378 530584 917261 161811 634967 169668 35019 426168 440428 844343 974298 561935 719316 486575 31899 629758 175809 772839 293097 434260 766746 623022 472582 709460 614005 104165 943699 920028 58946 215464 890720 405239 7917 365533 725545 363100 909032 995702 705038 169885 35658 340911 889104 966590 757098 951660 523730 806223 942905 44819 173667 660012 608482 19782 732301 328996 501759 762273 10271 115514 14527 725177 243039 32009 7876 803082 921591 267851 326415 101189 132098 75922 213278 201523 355291 210247 183175 73677 557161 516229 812601 880218 733429 288844 559228 642298 879412 908111 915688 71565 688755 253883 86674 353227 725069 128576 203260 413706 67774 774892 837932 272599 729794 247800 128981 812608 186783 346208 629681 839920 362056 308297 534821 144294 260746 4…
Output: 10

Example 3:

Input: 1169 670968 378160 493650 799440 148986 597920 197012 235968 581519 866580 247066 968009 716562 803702 73786 799061 200570 191231 190200 20038 102420 857766 204070 150076 13256 533217 56019 290906 779363 147090 305106 449984 948368 286238 549859 642030 10696 382723 587112 32508 397817 307199 812233 506306 584047 915128 942521 652701 992533 539735 542052 736142 205036 774004 14504 203176 557606 604300 940569 716294 155843 472996 357504 865104 863939 683145 789606 70700 976482 587761 939323 73051 135538 720139 189468 369589 494314 372299 945896 415024 938379 883387 936543 799477 58292 834169 371134 701065 236453 66045 447758 850438 453841 22424 206901 324850 409231 454194 203456 989984 926259 934198 596379 886966 30021 25314 301062 72460 93209 138461 868032 974854 385821 167939 192478 439653…
Output: 9

Constraints:

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

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