CT32772

Quade's Checker Stretch Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Quade the tallyman watches over the northern keep of Frostgate's stores of stretches. 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 <= 3028; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1483 267407512 176948208 494765957 45961289 719329645 885810126 674932512 213489846 4971209 245375624 817087419 991707624 680227389 430586425 865512700 761592740 663576914 66291026 304235754 392951164 628784518 213178801 47844134 370652724 134080960 2714063 964150210 783234787 884754642 503492314 63741708 804698927 751831486 848935559 815370606 375237787 67326492 203551572 971961090 679106084 205626276 134645303 649907965 600941362 504705496 860129705 648923871 190624088 778160009 598204551 363212607 394460107 332614223 199817421 833230803 603169395 514497117 427224781 121460998 576977109 122471724 518641183 601974613 982936281 15191886 316281386 443816362 980893878 658813562 997938038 768044809 715520674 852615525 811478567 211712962 195026991 340594337 99207314 894828620 478379877 329800…
Output: 11

Example 2:

Input: 1215 845307090 78774300 334678452 904092319 251601208 262966157 519010729 986058977 485640237 76760228 657920867 905002103 713012768 800796593 717944231 201836737 255590232 310920488 587925452 608578679 949294951 53779809 412025363 236340100 170036294 580160179 98864436 963336444 942927079 454026427 692630300 271141795 817561381 180669401 363492481 55125274 459787940 848605998 695979106 478890408 73470093 225279591 119566245 751929370 812838834 518765790 118437717 82016841 597550568 648674339 310721891 475039204 366816906 432288541 908102272 833318271 59841608 261861612 937683296 69257845 630527467 655497996 433954520 203220113 76760760 53659896 106521660 492928164 329220683 349179351 954987784 213953520 449572451 668941782 705307248 777074364 522588384 378631267 799964680 397811125 507059…
Output: 8

Example 3:

Input: 2161 799975530 297632513 913144140 389956865 194945417 667293637 953255189 270347243 575899516 706476722 471708208 791620131 375201712 958632213 785687049 485847168 988819583 704738755 826940733 166167718 689295503 923733327 811957971 271559124 958043678 433982955 202197903 955543345 9055816 277294032 69534785 737112348 377432832 434882970 510800021 307644670 767611156 257381163 758885703 244836410 688778925 424144577 302176663 832969032 793470092 21647853 434557440 633250836 979811478 928608442 44406394 262373772 454057662 435640010 555579183 501646312 808086985 96587358 415243494 722499375 153259690 860617284 551079002 825233469 441080629 277526830 651425917 176340935 793701529 583604623 959455148 183941009 44318625 382843145 60852838 59515801 539935058 870817258 432267027 230228276 2555…
Output: 11

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Quade's Checker Stretch Ledger - MEDIUM Coding Problem | CodeTikki