CT31801

Jatin's Ledger of segments

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the smokehouses of Brineport pays by the answer, and Jatin intends to earn it. First: the full register of segments. 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 <= 2382; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1265 -937647 -134965 -427469 -514902 -932278 -530855 -759876 -297569 -728349 -281189 -365214 -108242 -420713 -178587 -808327 -66205 -543176 -338473 -880889 -210117 -105214 -550523 -12170 -102323 -483023 -264372 -190087 -550889 -484543 -791388 -463280 -272943 -750791 -14908 -458715 -802785 -942851 -495760 -179663 -361835 -348226 -422283 -929282 -69537 -344483 -797438 -434535 -756006 -584552 -555713 -119581 -673522 -968988 -674482 -316487 -807020 -513112 -778719 -31607 -995038 -693079 -647993 -955584 -1974 -638654 -984032 -295355 -27848 -175043 -737053 -97702 -185941 -275587 -20649 -608432 -957446 -861631 -580210 -612061 -566262 -10485 -512702 -111554 -345477 -186869 -699164 -104234 -566600 -158698 -462942 -882344 -809027 -837225 -20175 -349127 -13057 -400234 -309914 -272569 -291324 -368296 …
Output: 1265

Example 2:

Input: 537 -420568 -626169 -706385 -811780 -357536 -60930 -706062 -835289 -344133 -354103 -127033 -201669 -874135 -769667 -580775 -145016 -630862 -838208 -626766 -749994 -451400 -640743 -993763 -923414 -686238 -273828 -281040 -541999 -185257 -857759 -638699 -175934 -781313 -996607 -927208 -209483 -460302 -462202 -422134 -772339 -99405 -351535 -975508 -991924 -436412 -909129 -348587 -788687 -202908 -422558 -938290 -230092 -803905 -847417 -853222 -440212 -454802 -687207 -796336 -74515 -952595 -384731 -173227 -579953 -405752 -504773 -923466 -784467 -538721 -40875 -960168 -247018 -949450 -514726 -674055 -634342 -561917 -467718 -519622 -836221 -306526 -815565 -44412 -272911 -869536 -871889 -838750 -84119 -731656 -836384 -990037 -134493 -301086 -475356 -559499 -290011 -255931 -575861 -656575 -833570 -3…
Output: 537

Example 3:

Input: 2173 -553428 -234223 -332191 -266281 -75217 -855993 -635134 -666231 -800420 -864569 -468051 -455810 -212642 -82632 -53641 -114077 -33801 -959910 -33524 -132335 -163931 -243296 -951164 -589045 -785944 -721010 -616603 -974800 -340191 -470790 -226214 -723893 -577588 -806926 -948761 -777839 -445045 -657537 -339078 -125082 -450149 -460786 -374679 -859499 -28379 -620478 -369112 -979401 -46081 -659871 -41473 -875783 -562301 -4117 -794466 -609051 -476121 -265671 -694386 -946995 -504366 -151380 -510112 -526222 -420529 -562346 -414329 -707329 -487539 -131380 -304813 -830185 -118421 -767875 -430209 -568293 -432855 -794894 -416852 -947391 -65227 -782743 -835670 -478610 -405734 -914850 -381112 -569553 -148209 -68124 -320300 -179780 -497108 -143203 -455826 -883752 -88454 -72878 -229056 -108209 -483227 -…
Output: 2173

Constraints:

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

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