CT29753

Librarian's Ledger of ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Librarian inherited the ferry office at the copper works of Verdigris along with its curious bookkeeping system for ribbons. Time to make sense of it. 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 <= 2532; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1190 596435252 258065203 404419866 38384843 353093950 929932409 924683231 522911594 324567025 350856143 726110444 78210038 652082654 656351094 600671685 888583312 101575285 254586918 55949166 433419390 444393223 861529258 287696998 364380610 268779582 412887386 920346578 361619008 99877754 373408984 296703297 967724444 88481743 421420366 686278580 701722691 928573620 70137849 602882199 221117522 293602280 408725723 252117237 313697002 225172254 492497967 98280338 666617685 204717158 284787731 214194771 935401974 486608086 493716136 146746103 662531664 327802775 562776063 520507158 252517148 518858049 907076949 178921260 964224585 570484410 557076192 499057308 889635414 459580111 672089723 157851731 403394619 589204724 522867058 956909126 922752293 177025646 906378650 389469751 15884849 284…
Output: 17

Example 2:

Input: 1442 332850154 487196786 339914893 771367144 742046778 431049292 838859302 383833241 630914279 356478408 202187573 235608081 119313308 470701687 915875869 220271503 412398584 810556766 321084700 907143549 317118593 924831288 474039958 822640517 211797121 724431928 80004718 369833235 900763233 539073011 561073346 101327864 655327648 758576416 834826999 927080440 126771452 423321259 788223356 124576243 846953078 9351096 108939193 672174370 647391101 692168641 507543311 190640605 532071845 256917895 881371474 197339327 890934923 672731769 497799285 650049908 811379452 423333269 490911433 660389775 553717925 769703848 787632333 362041928 923947320 255970303 646154259 270289146 62903215 777758540 250627933 476050914 405432020 371814112 30241201 17964987 486043094 552589264 162144386 660033367 9…
Output: 8

Example 3:

Input: 244 565185606 981228351 513258792 243086983 681690774 25535943 890625538 793718913 143048837 530317932 410415810 489426901 448972172 98303493 119022240 711962806 935115818 109619650 112406679 142806203 877072125 948559402 535456091 247135044 794125000 775202356 590715054 457318822 249340929 301147923 712912019 106232699 871394782 242117108 387810871 891982387 564811161 236007351 556425762 934805473 569284410 181394692 190547051 560149238 81818799 360603291 945961709 355457045 125273141 365518424 995034238 496735682 539541418 431017816 342824186 36838557 102879973 715528566 68239174 749311733 789458915 30951563 722673254 612268949 281323958 525858084 664326634 729119475 119164472 784706982 823337172 838429448 1564606 805842958 453782502 497462980 324217173 235097086 466264881 115568286 7475…
Output: 9

Constraints:

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

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