CT30634

Quartermaster's ribbons Zigzag Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the seal rocks of Barking Cove. Quartermaster spreads the ribbons records across the table and picks up a sharp pencil. 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 <= 2779; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 1267 -248888 -106156 -345607 -335015 -540741 -673706 -64515 -738947 -516042 -15230 -730674 -64412 -594369 -569979 -565326 -405935 -206086 -303654 -85067 -407955 -16369 -65038 -689720 -340267 -668376 -720440 -839697 -579115 -102249 -49702 -464873 -658186 -24396 -705195 -703394 -280378 -243271 -781864 -189436 -961352 -503703 -998310 -56634 -969590 -88728 -879198 -98350 -914405 -935672 -736364 -20160 -309807 -585923 -924772 -205211 -177692 -29405 -135468 -893089 -308748 -620773 -536221 -66632 -335901 -184138 -359093 -583802 -146286 -284362 -602219 -457651 -844076 -196715 -336302 -826401 -786888 -721688 -806830 -329788 -262578 -307715 -426710 -659154 -930246 -363014 -675341 -737662 -720230 -848680 -713830 -256274 -200668 -910564 -633503 -27669 -346956 -236892 -163543 -252646 -64807 -429379 -75…
Output: 1267

Example 2:

Input: 173 -762021 -585839 -953110 -241484 -300603 -435772 -192177 -18966 -72895 -661723 -867254 -181153 -441395 -243846 -200643 -988354 -952443 -291159 -751322 -881443 -812946 -12084 -782133 -911067 -504234 -54540 -559975 -301185 -901253 -891144 -785382 -791301 -899612 -314821 -464173 -158751 -855216 -799988 -649401 -505993 -815819 -663613 -951821 -836338 -809562 -768318 -894424 -452950 -17243 -298643 -502174 -416671 -864410 -385797 -554396 -880039 -996663 -105823 -596871 -832859 -201013 -798313 -609131 -216072 -367253 -959362 -170087 -773939 -794040 -511963 -999675 -743329 -503798 -594184 -444051 -952864 -784741 -952991 -107177 -842657 -575163 -918129 -222737 -167645 -9411 -119825 -695749 -698721 -947270 -177926 -153568 -352737 -343290 -809313 -765456 -467278 -727910 -659864 -723837 -200665 -66…
Output: 173

Example 3:

Input: 798 -240338 -87477 -921048 -3623 -477720 -111701 -969520 -111743 -408996 -506497 -553630 -477072 -260112 -138262 -685518 -230392 -225789 -94640 -465419 -605536 -238294 -13860 -107116 -82169 -139149 -810653 -64501 -163309 -926353 -814540 -277601 -975214 -976571 -457302 -488629 -767113 -911915 -245821 -578830 -480999 -897348 -266128 -639985 -494874 -852885 -837308 -249424 -554679 -100935 -116583 -799667 -521498 -116263 -66144 -284832 -234467 -432094 -909869 -18486 -131251 -892870 -967077 -767020 -457841 -303193 -87367 -942632 -661824 -632114 -970533 -159308 -328633 -516071 -3905 -828686 -978587 -606307 -446706 -772533 -448187 -683373 -800824 -537488 -705180 -424617 -335548 -553951 -351457 -197210 -52554 -856529 -226980 -712829 -152653 -569258 -628614 -43713 -535194 -146027 -618435 -644021 -3…
Output: 798

Constraints:

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

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