CT31174

The Pale Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the glass towers of Prismhaven, someone must outscore the rival chapter. This year the task falls to Notary, armed only with the scrolls register. 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 <= 2686; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 2353 942391959 154789283 369285952 927607705 921846950 190246245 917814189 866872013 751066523 88774487 881794262 4277936 31641599 451812075 920405340 967341181 91800019 84573358 66620820 634760856 311258248 25185601 700798800 817630069 46185060 170029375 101151190 934353365 19423157 832577368 949545298 527045950 475929651 584777362 658406392 308560999 695131861 176523128 473297473 386205142 949668937 948450228 613984351 852075480 257872483 164038101 197929111 924141726 965965982 933063032 588333526 57744101 627225220 878335674 731381 721903014 124328345 920946774 396486201 609886766 871120819 49927893 193576179 587728955 526132747 257659569 255963042 665643848 212154920 473560617 4951322 718866540 968074661 743928309 362002464 63310183 800742070 687372181 332079100 298940700 591418359 524…
Output: 10

Example 2:

Input: 1481 744638321 459512813 944174227 568522462 740321008 372654805 154847068 555936361 167343324 676571004 899744882 324603315 86609740 474502107 293002083 650270215 934484399 862916368 810246670 144306366 828466863 323655458 730880521 930894911 560856754 746430640 893598437 356882813 557200328 155402396 481407556 838111297 398433979 894973313 223973280 198627890 811607268 933216782 300739787 962008855 638355218 547157610 617515438 230660160 336020186 107177772 19433461 51759279 839118867 315873399 578335327 757981896 928407857 268316911 236508963 605509342 822229104 900844437 321655507 76560685 684373270 459792078 631747012 59754334 884933083 376932032 172602145 843175511 571053319 194946047 184515431 978815750 842043091 759301633 974225144 580105550 878925637 372908258 739715162 493328525 …
Output: 10

Example 3:

Input: 1232 414805916 687077823 747149720 947917361 552214513 584171722 67678222 872992361 877115224 744677847 516285284 39101324 123685874 -47037 854754460 487695926 49748932 336600721 517664232 217902151 694341432 97357889 647348704 900229687 173806066 353472191 495176817 477125654 464841387 995226479 971508470 960810904 287247208 300418262 119715957 106309683 730232768 77663697 569951386 540785638 843104321 642321373 670269786 470758333 515614331 513727821 490961002 447503833 554486413 72862092 342463563 850309644 263556260 203782271 778026144 201196713 81193191 453737218 433822470 31048061 301086565 981185221 232556240 523381306 886649297 924757377 278351487 844200541 983256786 166424423 337175968 950332940 702166271 646785 347576864 838477259 15638016 318399739 505443196 133938548 918425542 …
Output: 12

Constraints:

1 <= n <= 2686; -1000000 <= a[i] <= 1000000000.

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