CT29790

The Starlit stretches of Rohan

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the anvil district of Hammerfall opens only for a perfect tally of stretches. Rohan 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 <= 3173; 0 <= a[i] <= 1000000.

Example 1:

Input: 135 237156 734863 505755 301452 766507 917965 479626 263983 625133 731721 607305 719433 612004 11686 993557 251989 841778 308162 177606 128696 582487 951262 233148 12396 364130 558315 859091 724092 57538 430443 506050 674575 315592 829855 973168 201356 887869 702307 431785 884238 249551 697518 826059 784386 742451 278080 942365 959774 322494 946535 733548 623111 15451 59944 189432 89929 55659 671494 910349 995771 808067 326355 889256 353417 523730 454559 792750 369590 510787 159802 166707 923527 116312 547366 350090 902394 314069 170952 659670 866675 874477 41645 909743 468524 754117 369010 790240 200919 477471 299715 686173 252061 212803 523607 232350 747087 48627 9584 549879 124548 176136 832047 122860 917562 962515 397764 594675 419352 888328 799339 631976 4652 254155 823095 463576 5694…
Output: 10

Example 2:

Input: 1205 38634 26109 355342 406978 914163 709273 811125 931189 735340 930622 486217 944937 771043 293826 36821 896173 245753 970697 667043 904969 5155 304865 932303 392699 71890 10498 126183 15698 578860 733763 712941 356806 412105 781090 108132 554126 182630 506369 975330 609718 662647 628555 553831 897529 905103 756020 710761 463056 978187 855735 15399 129873 6536 809672 735890 559515 907658 727923 911562 870392 190474 152573 629942 272491 34296 210330 877937 418018 499395 140242 28829 685669 507917 773423 224631 655388 122714 857904 341497 994634 547498 439607 602937 407615 801117 913764 113994 527279 41024 49691 56140 214567 295078 780305 83869 864037 372578 661209 659410 86295 195911 825740 658807 5163 604727 60602 689392 878254 598978 632926 351355 279314 619614 793115 255647 301732 2540…
Output: 9

Example 3:

Input: 1713 311407 971020 166765 29788 830280 291674 929522 871372 77860 594513 924514 249345 836554 451533 456006 606327 225516 396302 453388 790612 661549 669988 206603 261804 28860 634279 685426 493424 433172 418636 408538 603843 994102 353039 899008 287296 245119 345327 9974 886940 251926 823519 673227 663672 299614 622450 399503 826115 600124 416530 345415 266075 17854 648603 953048 858125 839001 52356 780469 5823 258708 599865 91477 351139 591720 271091 902749 380266 551825 745692 875885 116348 753640 630007 194660 412477 769201 686057 359785 508223 452829 980540 955775 158475 68604 660467 312840 190377 231770 635740 64953 338860 111484 199037 624064 262038 504324 161823 800612 897725 617824 228474 208955 714988 360791 893373 346024 386828 520204 585004 177207 76191 201885 535513 301388 606…
Output: 15

Constraints:

1 <= n <= 3173; 0 <= a[i] <= 1000000.

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