CT32728

Xavi and the Starlit ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Xavi the auditor watches over the beacon hill of Lantern Tor's stores of ribbons. A careful computation stands between order and chaos. 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 <= 1018; 1 <= a[i] <= 1000000000.

Example 1:

Input: 926 95088379 808493238 516822839 270905221 784635594 123511828 260762469 78188802 269154858 645555073 826935363 557486483 123171426 965112649 373071170 599677177 683489682 728954798 238654832 664576649 852416051 926156245 444181081 857828103 695297911 412257083 303702527 451856420 786650798 859187795 398613521 48934930 939786628 880357215 927127647 950497775 976048369 141063297 563994412 146090248 52218062 348108088 472814561 220169928 596985686 246206244 314962546 502784011 693241549 671556919 855244193 379581164 707326464 439717345 770350306 620421353 906672347 787903048 77399145 544521701 121059390 12324319 527033292 14628312 509238137 322462584 282632065 324609444 567372180 935124150 263249995 891534180 495015302 199772227 456947360 622973423 868083212 370171034 804333407 868714054 204…
Output: 9

Example 2:

Input: 280 170485019 955105893 231552648 615064341 751122139 838649879 846830969 269732776 723109284 273779179 910938041 634785786 297897172 369107973 60444524 968551939 727186988 761382787 708152026 812600342 341518370 935550745 622843927 352491315 365676292 239833699 605428671 191980519 743155123 627428033 866871361 814350400 555058649 253802388 97314413 228257690 989714949 348019000 477346755 179365306 86877490 731739978 138902152 990343036 750483285 725309202 507063882 858518478 854804245 215264838 189993894 369968259 275514939 632363627 339962215 29920785 28696069 518720762 50173820 758786786 489704163 963527407 201728152 291628567 465106693 560712886 567440488 131734537 839653484 921994466 545401406 416536291 157408842 35522390 169368898 616992117 700742245 564589931 852641600 714172922 129…
Output: 10

Example 3:

Input: 776 94173886 658872565 576097150 53633747 778051213 976166983 450723826 234845285 441219824 876518580 942198447 879021323 79991653 84650175 911266410 434117217 888559138 743200973 666924456 132226168 106248202 966533220 513235553 939789541 601452158 225650169 617524630 907436415 447254365 489349961 583660691 35999036 541721167 738147306 128852351 755352701 557164795 869812354 674888029 438775022 980843959 698566986 435959588 250238642 167135704 778972838 934456763 893506341 983013063 58684315 123526044 298014709 221179685 474207385 7793773 51787220 504198482 57126980 367212024 132552059 790034399 108929431 604776961 688032966 529230614 863249370 443987157 155180748 379395698 896736875 185074408 245681003 894283477 725714243 290188844 166611637 753923246 647476612 289425212 282503621 710267…
Output: 12

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Xavi and the Starlit ribbons - MEDIUM Coding Problem | CodeTikki