CT32100

The Checker Stretch at Rustwood

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Marek found an old ledger of stretches in the loom house attic at the fox den of Rustwood. The margin notes pose a precise question. 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 <= 1568; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1212 -545274 -969214 -254358 -231428 -765412 -825267 -283370 -632606 -532794 -678869 -607534 -609399 -657385 -661018 -426259 -647408 -848998 -98512 -129193 -642899 -880237 -664995 -574132 -271017 -586513 -74574 -126350 -698192 -554715 -210635 -10080 -724208 -725046 -161066 -429839 -395412 -477086 -351710 -660518 -970345 -892939 -181007 -975790 -239338 -47036 -97370 -763613 -902456 -507009 -906520 -477491 -53355 -479039 -80249 -143722 -195701 -936499 -546912 -320638 -670339 -428481 -667440 -431232 -946156 -812263 -877551 -556412 -256460 -359862 -137689 -458872 -626445 -959098 -234294 -371961 -851241 -187886 -588567 -231058 -802322 -935215 -313935 -594743 -970024 -92471 -333554 -911256 -225634 -580029 -139619 -450276 -134015 -775690 -817325 -216215 -757680 -935639 -323723 -752251 -926121 -40…
Output: 11

Example 2:

Input: 444 -409590 -831471 -537185 -218758 -179614 -905772 -59734 -370156 -152271 -813146 -2621 -717707 -760732 -512005 -179450 -481608 -444429 -136116 -525738 -193504 -937744 -225741 -82528 -78192 -568502 -804676 -881131 -716674 -872248 -23594 -863744 -127189 -560683 -176075 -574435 -467922 -261120 -191572 -991457 -778684 -216321 -643562 -863328 -898245 -441632 -619452 -133645 -178715 -809379 -917231 -338735 -71092 -427675 -323669 -473501 -267083 -158193 -524652 -7899 -134242 -182064 -964947 -303945 -653746 -62587 -313064 -617759 -968741 -484631 -930125 -16183 -286808 -341916 -168276 -708042 -912871 -770263 -540172 -978057 -784379 -187074 -636900 -77349 -552195 -352327 -297904 -667812 -550914 -580277 -600785 -820908 -406163 -626179 -59106 -754163 -784115 -129472 -991837 -447003 -154507 -526515 -…
Output: 16

Example 3:

Input: 1429 -81763 -689342 -714002 -686989 -537342 -465265 -683235 -336061 -557380 -902626 -716813 -630493 -542617 -109206 -695107 -98019 -33153 -357196 -69495 -701052 -12674 -489568 -798227 -405819 -149610 -270046 -944239 -941177 -929114 -978106 -653243 -973759 -715334 -906898 -328247 -842617 -828272 -450749 -399460 -754332 -593306 -687958 -719807 -40336 -968059 -633744 -7752 -523451 -504633 -149112 -678088 -179953 -792139 -81574 -329206 -184192 -231588 -426702 -981024 -290228 -772442 -315646 -899085 -31296 -582369 -472775 -627190 -553266 -236639 -637976 -591648 -890569 -648160 -848493 -910046 -253011 -189746 -59734 -798716 -544460 -933966 -224191 -987253 -509874 -480319 -183283 -342352 -620421 -915990 -372929 -156074 -925898 -66135 -586157 -44676 -557079 -279443 -457887 -236075 -324734 -474806 …
Output: 12

Constraints:

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

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