CT33166

The Checker Stretch at Lodebarrow

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the silver mines of Lodebarrow, Iris records each segments in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1198; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 551 629229748 629437889 623683830 126713735 423922461 742424493 230416031 206857400 842430088 417228085 291349044 675426421 236345110 688410655 752913038 83382893 302562967 314039500 131417163 77434078 422988991 701821304 920037708 7538011 708198242 635513871 859563881 868514587 622239368 454174460 971710975 481219759 972683117 869856633 300744672 403010729 931083667 10445322 757165777 799904773 645562165 983576135 143652193 197801645 562336302 767716415 791756261 862801852 789401055 132207626 428730836 664288307 680389734 650198247 595169745 401938463 779061097 7027524 55247384 636205742 801161578 771724776 635228416 239081530 826115869 552959173 348930698 482861141 602932343 230665830 641087368 921718702 244214071 350094427 751842741 485587809 558347367 718208939 940815699 628215284 2192…
Output: 8

Example 2:

Input: 936 56758200 422430701 860082198 447559041 809263652 32892046 500181377 759608481 590362050 721123582 930015170 347447505 640201511 815696612 238830579 171157636 818274691 426097585 789265026 994422994 908668457 785934212 343883740 171027715 587753227 192689894 920489209 389302004 456923546 807167733 100722325 -250309 268438871 165459069 794356687 54308173 156715717 411856435 928014775 583189234 927479835 344494918 482453385 320787503 320562083 718751435 913838812 905640165 574081553 36934855 143570979 824594975 733902098 145903455 749621908 412115110 636087532 771743562 236962337 158972319 822887073 644228602 825297250 155287118 158684537 945991764 174740435 154865011 441752172 353178256 805736076 657240886 101685770 757565401 660259738 274689155 470775869 751084604 138353470 225945662 50…
Output: 10

Example 3:

Input: 927 472885819 261524836 89440772 793108291 391139249 527920851 605643964 230900861 499522133 327101302 975967591 187547053 509855481 66343404 980847825 993730876 282155318 760643834 40973660 949117921 654082007 127971822 550829948 718803545 875589868 430747271 887791717 781334788 281516966 906809700 520952566 396949651 919722025 865123127 422630796 533098785 451890912 185644384 544005934 969258996 259155494 152812553 330830622 834277608 288393909 650112494 413511507 87016763 846259248 172717551 392035398 80203859 566423690 941829672 914970758 992266712 551943086 626112785 632635901 564062960 970080904 640049537 868677953 557626394 951418500 200641002 169929636 991618412 93928234 597021080 206750599 88012288 795219961 447998499 986500724 745000925 488791149 589171260 547842216 689580090 230…
Output: 11

Constraints:

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

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