CT29559

The Dusky ribbons of Ulmar

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the galleon yard of Masthead, Ulmar the archivist keeps careful count of the ribbons. plan the beacon maintenance rota, every figure matters. 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 <= 3159; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 993 -542685 -427260 -744517 -986782 -137200 -649300 -493116 -708357 -981370 -654980 -347211 -246005 -252322 -944605 -599403 -707593 -906667 -658597 -664032 -767960 -337858 -720341 -385180 -304101 -227857 -597507 -970584 -335551 -253375 -848258 -154070 -717720 -823496 -103803 -290935 -524813 -891948 -920108 -247866 -869616 -88883 -459302 -532038 -76939 -728136 -611947 -839172 -423971 -647171 -172128 -715300 -423724 -832635 -479351 -842258 -71881 -321087 -463470 -679672 -601233 -689283 -888210 -826811 -344908 -654303 -116565 -885093 -487384 -483067 -890115 -98140 -741739 -885444 -153940 -488471 -754806 -672164 -645142 -145135 -672247 -729901 -613645 -26637 -624151 -659122 -632618 -362446 -424279 -439628 -666975 -616069 -635437 -176473 -472492 -648681 -251451 -894873 -446303 -617314 -664011 -…
Output: 993

Example 2:

Input: 1781 -972384 -572713 -562070 -508492 -54927 -730658 -912343 -409492 -766169 -17153 -379308 -269002 -440088 -298445 -137696 -390256 -318615 -453056 -643953 -609654 -447898 -589346 -998247 -900907 -44604 -430712 -739088 -40631 -299055 -819473 -58813 -429888 -104282 -470953 -531521 -855926 -699134 -175048 -854117 -220605 -54566 -260478 -584846 -541686 -501862 -112557 -334269 -720679 -423091 -873602 -416497 -211764 -30654 -8073 -318905 -969620 -697862 -695059 -121249 -92266 -418680 -253834 -100404 -16645 -872001 -104652 -593558 -783523 -369985 -982207 -414786 -577051 -354424 -348345 -345473 -284729 -570372 -478249 -655099 -595871 -291310 -575092 -970709 -251334 -753026 -993149 -19754 -451534 -743421 -54863 -859857 -834341 -388398 -377403 -900565 -437481 -12555 -184968 -890970 -810862 -529532 -…
Output: 1781

Example 3:

Input: 749 -663632 -823689 -872972 -219608 -632977 -246715 -262299 -619473 -614351 -172519 -636597 -260926 -901697 -532370 -232663 -199344 -840691 -628045 -295019 -910356 -400830 -831613 -136215 -212404 -28623 -375084 -924888 -302200 -316954 -632342 -727773 -424093 -244887 -237316 -624573 -208657 -505163 -23417 -197138 -966579 -592050 -33919 -436355 -494064 -960018 -729854 -83672 -928023 -312239 -168859 -602461 -87286 -690673 -729763 -245804 -744699 -305567 -143950 -955024 -432522 -723173 -430328 -680025 -959330 -112925 -396774 -333087 -387949 -573293 -80653 -125933 -114102 -565775 -193073 -455284 -290503 -247721 -811483 -874595 -386401 -885302 -74816 -973245 -598098 -953075 -764934 -719385 -670072 -698186 -747554 -548317 -172196 -245749 -111949 -407860 -443341 -501478 -501453 -774068 -294726 -70…
Output: 749

Constraints:

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

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