CT34559

The Faded stretches of Zara

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the wheat plains of Amberfield with crates of stretches, and Zara the measurer must account for every last one. 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 <= 3294; -1000000 <= a[i] <= 1000.

Example 1:

Input: 2160 -890465 -758023 -359460 -750593 -15331 -965426 -483749 -790962 -269199 -828528 -660419 -483123 -8472 -574618 -745512 -187562 -37916 -940005 -423128 -256732 -680459 -847282 -601272 -396943 -635761 -69045 -869560 -552721 -108615 -806586 -203341 -68829 -601313 -665386 -970122 -231039 -379815 -601128 -455517 -916161 -695774 -235917 -832341 -669886 -632036 -693237 -526509 -62776 -671336 -542365 -16940 -561727 -101881 -723331 -257480 -813682 -221548 -829106 -698852 -121564 -940509 -97887 -845626 -603432 -456469 -91820 -8972 -870253 -322156 -492556 -66025 -253993 -873788 -987914 -863664 -89268 -403773 -709679 -263076 -685445 -129627 -148749 -443985 -679823 -934209 -841080 -743056 -160569 -813912 -664633 -565204 -111264 -902030 -215952 -985417 -480230 -343619 -978847 -565297 -656107 -518237 -…
Output: 2160

Example 2:

Input: 319 -360085 -296484 -864140 -586720 -775466 -352227 -750258 -989972 -992078 -761962 -818689 -383619 -842436 -943568 -71448 -755087 -43146 -545068 -153442 -8574 -472646 -868634 -225188 -474448 -735644 -960323 -977578 -845215 -557729 -553645 -829331 -504545 -684816 -976210 -963202 -216245 -195207 -131929 -565099 -342144 -782610 -79536 -441626 -989924 -855774 -359983 -693497 -988865 -775932 -809667 -349956 -210861 -103177 -966938 -659035 -599025 -878534 -305873 -366152 -695355 -926975 -51851 -930450 -978413 -903378 -326136 -840739 -466697 -42803 -465651 -39233 -563947 -179826 -461342 -540697 -789432 -432352 -538524 -11629 -313134 -735805 -131538 -41670 -392333 -397151 -979989 -91900 -122881 -537397 -270366 -855172 -752079 -163988 -808845 -995429 -116204 -875307 -423106 -600294 -947286 -674732…
Output: 319

Example 3:

Input: 2486 -402549 -321106 -690303 -944579 -333663 -921908 -133969 -472800 -606654 -981111 -406594 -631915 -959399 -682637 -525996 -366608 -337686 -642612 -338918 -658214 -983258 -76097 -157555 -558536 -624370 -341654 -123087 -690948 -299942 -767176 -553833 -890315 -38840 -308935 -722672 -200676 -877975 -425377 -616606 -176716 -113708 -600773 -395953 -327326 -669794 -140568 -100860 -863918 -363390 -876177 -816141 -720291 -735350 -612818 -767991 -309511 -730135 -993819 -7134 -756919 -782990 -669277 -913725 -163144 -285225 -702773 -907185 -711531 -235385 -29267 -913083 -456775 -610756 -711675 -860506 -988974 -786834 -568406 -223199 -326735 -352658 -955775 -906956 -885524 -212171 -827899 -930314 -518677 -474277 -692186 -646411 -385019 -137357 -179139 -903068 -924409 -431747 -916387 -595512 -139959 …
Output: 2486

Constraints:

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

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