CT32291

The segments at Glowfen

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the lantern district of Glowfen as Kavya unrolls the day's manifest of segments. The tally will decide the next shipment. 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 <= 3555; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 3355 -536415 -788171 -660514 -227343 -313672 -321831 -285256 -211320 -84905 -577584 -867889 -574680 -235161 -705310 -620498 -464367 -440024 -99768 -901718 -597725 -333958 -733971 -519733 -272281 -780608 -270760 -638008 -527201 -441660 -689374 -550242 -265108 -642823 -650453 -4683 -519418 -91788 -365757 -536977 -637362 -23446 -969922 -634724 -403868 -383637 -852629 -203298 -456689 -210136 -974351 -284446 -384115 -820834 -493941 -545067 -333055 -2115 -448716 -197431 -663050 -310589 -884519 -207622 -185134 -878004 -800983 -82739 -116134 -223466 -254577 -858205 -814109 -229357 -735718 -846720 -885665 -439200 -738395 -334775 -722043 -403536 -724273 -286607 -605191 -894949 -671470 -166875 -770759 -354166 -214159 -603937 -776820 -284030 -23711 -513461 -864571 -617475 -191860 -197434 -738480 -2423…
Output: 3355

Example 2:

Input: 2134 -337595 -511702 -417740 -226629 -408925 -914465 -722401 -244499 -29149 -851861 -529577 -949669 -583464 -224060 -672696 -856398 -713579 -108482 -679821 -219774 -142424 -31689 -774584 -185546 -873059 -467370 -568862 -67718 -963474 -122792 -436967 -92930 -130911 -921582 -869192 -706376 -43447 -988189 -791770 -37612 -170761 -487141 -961818 -895932 -814571 -142825 -356700 -283828 -662894 -435065 -812524 -466015 -904401 -816284 -156425 -103935 -239582 -389108 -818338 -502513 -909129 -12545 -879939 -628387 -511889 -479920 -139688 -521873 -241980 -342179 -564031 -426939 -25065 -814824 -452869 -364801 -177553 -871084 -612219 -706582 -311710 -630278 -364016 -669114 -519166 -399538 -873733 -72608 -471684 -796295 -142844 -143667 -729345 -140872 -198492 -172752 -58272 -773597 -985199 -146935 -9491…
Output: 2134

Example 3:

Input: 1649 -196788 -226508 -132871 -293881 -306179 -997364 -836321 -117450 -28902 -149273 -355162 -448826 -214684 -942532 -931319 -242860 -824282 -499475 -7930 -927156 -72297 -745114 -599590 -317303 -267864 -172898 -984321 -314225 -11472 -211959 -983164 -152377 -963594 -452887 -188474 -559371 -439793 -913169 -449627 -44195 -124869 -459842 -601212 -558122 -790062 -222513 -337419 -647408 -520374 -406836 -118965 -941222 -302339 -966662 -310297 -872167 -549337 -811998 -307857 -798815 -305439 -652303 -320363 -280850 -500031 -618048 -715095 -195370 -959549 -531939 -9091 -585832 -353142 -864360 -992910 -653221 -947453 -475688 -618054 -457861 -52036 -234054 -164853 -611413 -280662 -150365 -118486 -884188 -231301 -487086 -122551 -908134 -510239 -453352 -170304 -382634 -409865 -860940 -875307 -149461 -455…
Output: 1649

Constraints:

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

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