CT33771

Lara's windows Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the seal rocks of Barking Cove opens only for a perfect tally of windows. Lara means to find out. 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 <= 2245; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 2143 919897056 338040026 971214292 544301800 839981289 764625150 789564403 285858744 505218668 886317442 191695221 677344799 249159223 911010253 273757806 693476590 438577452 98199989 532547375 801379250 640256430 418286761 844160732 778513032 320670851 389085012 849393307 444250822 341191563 313184247 777490694 399307143 936254043 404240323 137406731 380197689 185430325 671364781 302868725 928097581 308028174 343088674 245180086 23796809 804900935 948069902 882651743 882987920 873341132 20500551 469697120 949344362 341439814 853466773 931058307 490596195 956116823 732148830 438803449 446286911 489789074 706568833 568904671 112108207 31426078 311786682 264291878 739265312 340307271 823040539 517180271 623606905 214608278 278749500 26106496 611494293 767762343 371618275 392507359 429207795 …
Output: 11

Example 2:

Input: 27 689284964 264800457 893257420 85206143 448989973 202351282 784807525 257194139 811183863 621340060 148798354 684400843 444736315 965974509 672732190 664741645 397439316 537623907 501413582 964656295 919966306 570660896 699984502 146805597 978175894 747828311 43286931
Output: 8

Example 3:

Input: 2028 497611943 511317726 999984273 697865281 599004518 854401065 50961503 605723456 650597205 816649831 226649833 675581662 740443074 11122517 471488859 389418537 296235356 720636818 910455810 515268222 955414232 769190952 54540104 996268571 534022172 189056613 267025696 163554593 469868080 977893814 165062082 766837635 664940106 313225124 337956809 653928133 983816310 876094453 481524350 939043848 135936956 466766127 682410755 594826712 473556786 568009287 29368545 734724412 650723176 425570928 454280592 484864807 509297545 708253539 187269992 384018022 956107558 737511325 426588547 388398562 390925599 806369060 209974881 410935706 946916594 859593082 891317935 758128123 771027418 152862082 633108126 713707130 334299357 145969575 789488026 472340791 777807349 519554258 655034221 522289578…
Output: 13

Constraints:

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

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