CT29377

Harper's Ember scrolls

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the peat bogs of Mossgrieve close for winter, Harper must finish the scrolls ledger - one figure at a time. 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 <= 1040; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 591 782390458 130833111 498779414 466914460 598656211 391030198 885117378 631756242 908872511 58134925 448245379 934221316 202920764 529944633 970660832 947646514 401358276 204913595 864861051 803292776 127567819 698520803 262377567 599017190 260546010 142466321 150780498 395548481 629846540 517936783 398999431 561794996 451780440 674339675 24033470 712712930 623807416 186256671 110311322 429596395 39346177 957854545 914925141 271559785 138708860 350837429 518334850 318415217 991351015 359992139 191948441 743228978 949188451 11653757 336237635 298009175 423420687 615528124 752656213 35771365 278179786 240481449 884126192 269702931 227502164 767114214 64139633 481469013 776058721 422930869 661447084 381885298 686094811 344224183 926108968 957928395 877193778 586700749 454145798 806393909 88…
Output: 9

Example 2:

Input: 445 422615796 1501141 156241018 798897945 726851641 359675121 498952237 390588958 495484842 358894807 798239414 924238179 269202596 520781532 730202903 733509735 684795013 641105778 205152552 9907732 787117373 896519694 849052209 372464779 919706754 816046572 291700339 771331183 356423313 672842943 785167854 826079137 367178475 229200860 53374775 624001423 157525750 897028820 522425728 25328530 214209005 987167965 535283705 350494244 296938890 600080795 723765701 264918947 417169105 211690466 649265297 262291877 57270927 331769750 953222605 662412468 623406085 428977920 287404904 472229323 981563182 819209330 56170529 919140918 326548739 88577739 551688257 291043521 122309630 648311901 609138485 887445308 348272548 302338598 77944357 29840067 60248760 57180777 481714839 325838692 768821030…
Output: 8

Example 3:

Input: 382 241213745 264976437 919809788 890856794 787537316 39894018 959980141 169190034 201283798 274453290 93849116 282733555 903768808 211533607 293450676 548156793 670321745 89154587 787381241 869516110 364755031 217805488 150567203 989762432 370671749 903809670 254040059 60209935 359015564 719056715 745357240 160678978 341301262 760685956 349065633 323340670 733155031 735985993 732358002 707920353 164695399 164710622 280927828 449022205 898663486 104409863 224115976 646599603 76139236 405854260 612281429 417696563 138127157 942885528 66576836 743138684 789927715 869325346 485398485 314001836 41424659 266226021 608552295 919994811 125812419 972394249 898631092 570777029 349615085 485550766 819598506 405729712 24767081 845747611 347555932 205243697 64958773 463007699 871176358 891605960 25018…
Output: 9

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Harper's Ember scrolls - MEDIUM Coding Problem | CodeTikki