CT31497

Manav and the Zigzag Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the orchard lands of Applerun, Manav studies rows of windows entries. One clean number will settle the guild's oldest argument. Task: Print the length of the longest contiguous run in which every two consecutive elements differ. Input format: First line: n. Second line: n integers. Output format: Print the maximum alternating run length. Constraints: 1 <= n <= 2030; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1897 -377159 -882140 -996230 -301183 -259518 -34438 -931214 -593213 -903914 -125017 -997821 -499163 -561794 -796330 -316134 -191935 -554015 -770686 -182818 -656584 -989305 -709950 -501431 -154909 -83425 -44999 -134762 -155259 -818465 -839637 -74774 -638846 -26921 -827843 -76630 -724956 -440654 -691558 -787186 -751700 -437200 -860828 -649312 -878799 -131902 -903768 -523783 -226150 -397832 -594420 -635667 -529500 -160969 -564735 -172731 -7717 -740858 -677910 -75506 -462293 -632502 -743830 -657076 -953014 -953889 -873048 -569159 -868626 -622350 -594049 -654193 -783228 -276699 -419551 -613090 -654599 -955047 -725000 -792363 -703846 -806140 -920500 -853643 -224249 -784321 -344781 -692344 -935363 -708944 -24834 -283969 -987255 -652542 -4464 -307493 -167532 -802951 -304226 -44278 -782066 -702932 …
Output: 1897

Example 2:

Input: 1590 -93634 -51563 -166137 -274388 -263413 -540779 -974101 -360944 -163844 -961472 -850948 -204258 -664339 -864528 -308871 -272380 -284702 -930305 -603444 -275537 -968479 -244810 -623908 -657368 -503079 -424042 -379769 -847825 -501587 -886773 -198007 -243681 -761890 -216295 -208037 -854443 -257984 -826302 -683830 -419259 -587800 -524449 -814774 -970735 -181971 -486001 -917942 -146890 -25832 -526442 -992227 -165077 -470471 -835475 -758698 -914188 -300320 -805157 -61855 -842261 -701251 -422389 -33478 -188487 -567378 -884237 -767874 -837130 -531641 -783502 -357218 -285132 -240728 -289300 -276145 -570425 -77537 -589842 -947902 -310184 -389268 -985347 -309480 -761062 -955027 -930500 -513022 -582855 -906682 -647506 -865029 -621086 -490035 -314893 -271345 -776451 -996347 -212641 -65823 -706733 -6…
Output: 1590

Example 3:

Input: 1298 -413760 -142173 -768643 -999111 -334896 -402079 -853697 -120913 -271099 -706062 -371365 -298087 -600069 -861698 -303875 -693328 -956385 -469194 -948275 -141365 -531613 -847884 -397677 -660949 -728091 -883135 -89576 -533308 -72849 -704194 -283540 -631818 -761449 -326417 -553003 -287445 -297512 -385512 -597453 -152420 -541329 -929656 -659208 -578121 -299517 -349341 -774903 -464769 -545870 -765883 -379628 -253742 -451984 -28466 -839155 -7107 -577180 -113134 -84460 -62565 -174652 -365199 -401985 -211572 -353190 -986016 -474802 -112825 -266622 -826353 -728375 -108781 -768919 -333870 -801820 -694412 -581641 -179358 -263701 -218032 -502498 -372953 -994080 -366477 -586850 -219614 -152343 -18531 -801020 -108636 -239183 -81968 -291115 -529019 -521366 -490748 -461943 -859293 -284146 -223421 -952…
Output: 1298

Constraints:

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

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