CT34983

The Checker Stretch of the Secret segments

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Sarla found an old ledger of segments in the dairy attic at the acacia flats of Thornveld. The margin notes pose a precise question. 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 <= 2319; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1260 128352762 510887313 657915233 749963273 601454295 413347687 675234206 911539172 939769806 338200097 277607791 549365576 800053911 649248851 836124019 892057349 605803624 375759563 152507297 67895659 14893592 67814326 47684171 69451818 821189609 820473930 316542849 372257157 593620803 797507769 945800470 367805243 422495153 849546217 863253166 219987535 566542364 297334209 428918472 307378697 869088120 391756741 825735937 25960176 978191809 307195141 899567354 724929955 734012370 82346332 757664923 990394655 499314752 183483854 476908853 38660423 370028016 318037526 194852045 813584032 68369735 730857567 317548787 398964170 105999969 953413646 517377664 813493429 694113519 637338075 267224659 518437671 188732665 660640773 308652364 289084406 818745157 541802430 391292848 963556458 5031…
Output: 12

Example 2:

Input: 2142 86018049 709998925 199972885 730523057 272788014 837307223 618249823 558565979 354130239 912512894 370782733 93936902 809138307 473680637 697285996 374473040 224793555 225198940 873356592 633587856 381418714 461462843 171625512 439869896 524906435 744021677 242957864 490660172 728617858 851890599 787587740 60077764 293131140 791508080 512025500 581109341 288942785 438966601 164503376 46453909 9249170 529979267 247680165 986030952 957125214 758300622 309268835 399788528 323598603 144439026 642727833 500143210 306831321 184007227 500750861 220653885 35492020 365291998 859281321 967301142 149740964 319894582 360295087 219893883 822150352 338168888 539942519 309484671 988323293 469252601 445902985 742807851 326370902 76596688 8292579 576437382 871116017 799371752 926984457 198883174 68304…
Output: 18

Example 3:

Input: 2236 224470429 632409111 564043366 244662336 492023054 671439041 316058738 205978334 506412615 474424083 925032169 297143002 407384927 664429172 678130734 863586187 153625008 246182261 85695128 867348354 79029684 140040184 159809540 541089585 885013253 775546811 827927461 857163916 786658410 448898322 279964814 300318970 707818209 849515000 606145557 334603742 108424812 420434669 384661330 789138407 534415056 690028544 365828953 67420993 343107346 437355125 604004373 673030304 132791465 678584329 550616324 774407350 169917828 427889467 671291141 844369866 803773970 49454670 698140073 926042158 655460907 451153631 949266431 522206413 419577410 684298798 935398821 951316206 438459455 672290951 816224285 947826794 416052651 541399805 480738095 66188607 562385672 571692766 681522175 219259183 …
Output: 10

Constraints:

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

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