CT27931

Botanist's Crimson windows

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Every season at the northern keep of Frostgate, someone must rebuild the damaged itinerary. This year the task falls to Botanist, armed only with the windows register. 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 <= 520; -1000000 <= a[i] <= 1000.

Example 1:

Input: 129 -285673 -376525 -828106 -624655 -555213 -101985 -801340 -359730 -228090 -497063 -568752 -9707 -318779 -813071 -584128 -462014 -394012 -862450 -741107 -791616 -625774 -140003 -685140 -155947 -23400 -380570 -966998 -243587 -68182 -545358 -799977 -56507 -679213 -871615 -856386 -847475 -455959 -339256 -736113 -185363 -814890 -745247 -705014 -673629 -722343 -186383 -818356 -753223 -852947 -823516 -470044 -34850 -983482 -893276 -38382 -168736 -704180 -177360 -69649 -207564 -413681 -657530 -835173 -530213 -627320 -457731 -367742 -990869 -423321 -67884 -661374 -377678 -611185 -910672 -93024 -722013 -986005 -98974 -289992 -58765 -724300 -423655 -233430 -644878 -581757 -376823 -440600 -134180 -944457 -52921 -258918 -718601 -452974 -316007 -50847 -373753 -890257 -67902 -565583 -82145 -241597 -983…
Output: 6

Example 2:

Input: 259 -74299 -21361 -249634 -154911 -248486 -260826 -976238 -713226 -656152 -551928 -377031 -644396 -884704 -795045 -196559 -242211 -363688 -726863 -128506 -722030 -243911 -840838 -445994 -447394 -508213 -354961 -53350 -539771 -748812 -520668 -262865 -355866 -893818 -456017 -658884 -443495 -477257 -354872 -182815 -753119 -298126 -18351 -127477 -342955 -545558 -878829 -309434 -265016 -456901 -807535 -919132 -454895 -938303 -529999 -56661 -302380 -333218 -240180 -860939 -628785 -693560 -294085 -458047 -8940 -884427 -607461 -779800 -14284 -95082 -267358 -793062 -831868 -635338 -170531 -906300 -107507 -628473 -354641 -790209 -132590 -329350 -587809 -666932 -448004 -965142 -999313 -247271 -631346 -586668 -975731 -389159 -457042 -978201 -437602 -827673 -17321 -409520 -244714 -678901 -264578 -33634…
Output: 7

Example 3:

Input: 446 -606755 -969899 -780818 -121985 -430119 -529707 -497287 -149032 -741599 -821571 -554826 -321450 -11309 -809806 -2879 -603453 -642129 -362921 -683855 -791956 -305425 -317498 -297699 -809940 -254243 -355310 -751221 -432560 -461847 -982358 -423979 -543486 -219973 -812182 -165537 -808299 -426800 -57507 -644422 -480562 -357919 -196651 -975051 -109288 -50034 -255372 -323144 -28567 -16855 -202590 -531667 -316513 -494458 -835293 -787882 -345773 -739200 -764702 -346771 -532219 -185546 -236446 -960089 -908077 -260377 -336322 -867648 -743904 -220471 -177130 -656459 -954924 -218629 -657461 -434058 -898615 -587886 -480619 -308066 -130917 -821372 -785222 -481467 -17508 -630445 -255167 -979362 -925596 -191529 -459696 -787442 -990811 -422702 -906738 -535994 -537253 -519015 -906288 -133919 -260750 -262…
Output: 17

Constraints:

1 <= n <= 520; -1000000 <= a[i] <= 1000.

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