CT33510

The Checker Stretch of the Crimson windows

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the ivy courts of Vineward, Dora the scribe keeps careful count of the windows. Plan the festival budget, 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 <= 3250; 1 <= a[i] <= 1000000.

Example 1:

Input: 414 966458 48286 809771 325593 64759 716295 725339 779404 214683 986145 24693 772264 952578 917845 406842 614495 620796 509698 665879 601585 513806 890410 344647 704767 787323 441341 864453 898965 957795 831681 37053 882285 269160 394074 494374 749944 347281 714853 626314 382815 413841 514746 975902 668807 413933 7592 795443 398454 870209 459293 513494 324814 476160 219099 772254 505905 381757 270735 384866 218490 892311 58637 989306 736319 886107 614086 658606 783657 182194 475229 756404 257385 642061 167682 273730 997533 56474 330964 344095 480406 313536 91286 39561 414409 227762 79120 162393 169511 223202 352365 903259 50400 666279 691771 915268 761297 102247 634236 919007 694441 96299 433558 938915 854922 472754 886968 782751 100072 429909 186340 303730 492180 482845 753614 207937 2521…
Output: 12

Example 2:

Input: 2589 613331 180401 854309 285206 380903 921706 625021 396565 96889 116091 801983 454917 764866 332355 949644 840541 81159 791060 508612 58372 663186 976647 924911 520062 411422 417568 195781 533763 698538 988902 183077 462922 622098 728605 264732 628351 812371 8310 923365 343955 521417 673004 653756 467020 51260 497856 705918 16710 367844 277857 215860 793917 234301 962570 836589 144349 549472 931294 21441 829880 357406 778721 384455 467591 223318 382226 781926 915923 896209 736912 288256 878016 943513 901400 428437 303738 597982 571928 788613 418586 790458 252421 350522 133184 208459 645360 814377 447525 332304 685509 442780 671607 558082 693622 334415 623712 114289 145835 286357 149454 741676 690903 975679 776428 725327 376076 644402 404436 620645 382974 371956 162646 191448 729328 70301…
Output: 11

Example 3:

Input: 1071 149151 909340 568228 462114 465965 923077 530726 473389 27056 745627 667123 315866 353473 727386 689448 692915 97902 970610 470668 731654 88463 343338 708111 786797 439879 229831 271029 882918 354234 447451 902544 770821 836316 207265 378738 964410 44277 943669 455565 760524 947696 365182 455089 192040 22842 917697 650014 481683 362852 381092 317340 28254 459778 52592 374970 279796 555402 309658 346898 615817 823696 296076 762520 538631 235192 736908 360736 370110 428190 310945 390175 996177 492261 625627 852883 229120 920733 295016 117840 98785 662918 312344 159634 49444 567878 938102 564579 566438 925584 204523 257631 79186 818662 693601 651227 298224 580968 890226 382800 286970 353664 938602 886331 687332 602502 978864 219736 38829 228418 987273 282275 201800 346188 896603 116177 8…
Output: 9

Constraints:

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

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