CT32792

Tara's Zigzag Stretch Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the wheat plains of Amberfield pays by the answer, and Tara 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 <= 1513; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 611 -888487 -162187 -668444 -322507 -758498 -185661 -572447 -489171 -260525 -169173 -843800 -453836 -384544 -822660 -863403 -865116 -91631 -402117 -415968 -891567 -590454 -184116 -238140 -147120 -180812 -172984 -825070 -718346 -901725 -849061 -98100 -240958 -223459 -168980 -843855 -779943 -601897 -252456 -53357 -630033 -567376 -360877 -244570 -531664 -284457 -76346 -584600 -614387 -584775 -937798 -622946 -8429 -447603 -939254 -148687 -693369 -347598 -63895 -270720 -567878 -430047 -355825 -795150 -620195 -816191 -521066 -678033 -198538 -266219 -289463 -629567 -752017 -975823 -377862 -568590 -142865 -900887 -213954 -402337 -719529 -275074 -410832 -671646 -598908 -400424 -852879 -475271 -143208 -309881 -592711 -920799 -848902 -307989 -78642 -139169 -522173 -599631 -18818 -474148 -755486 -4402…
Output: 611

Example 2:

Input: 915 -725412 -508598 -470722 -699635 -293508 -190918 -834190 -975709 -48042 -888800 -967154 -304883 -582722 -808179 -596374 -520436 -457404 -790215 -420015 -335248 -492434 -292942 -546354 -620351 -932347 -206850 -844232 -18453 -342890 -444556 -272176 -647234 -142624 -228894 -355366 -714693 -223754 -934677 -503951 -961070 -365451 -699039 -792643 -243314 -769776 -408755 -453222 -479851 -32448 -517208 -116675 -305839 -479569 -46097 -955781 -845633 -266454 -609729 -468527 -436471 -903477 -456656 -2026 -721201 -849843 -774613 -373198 -631587 -93532 -854186 -225800 -579856 -420778 -454596 -831131 -871066 -347153 -79525 -5997 -348597 -60118 -756473 -317743 -376461 -817208 -933096 -16392 -937897 -505753 -796251 -734805 -715434 -582261 -564420 -698891 -920219 -553035 -265786 -237070 -215701 -243426 …
Output: 915

Example 3:

Input: 837 -703834 -997881 -989133 -903618 -64086 -159460 -961633 -19258 -312445 -903026 -96439 -293185 -503743 -515949 -853120 -445574 -802912 -783253 -73752 -228500 -871078 -692087 -461449 -155004 -999870 -888381 -282823 -981532 -138608 -170774 -387286 -259404 -505461 -275286 -249192 -882283 -891493 -730094 -906998 -65461 -902669 -801817 -955275 -6945 -163473 -34342 -955085 -779252 -447291 -539552 -597360 -761681 -378416 -493986 -136728 -525761 -613408 -434457 -763957 -248566 -199469 -65472 -11872 -114646 -949441 -464934 -402440 -36271 -795565 -886293 -452422 -134259 -677078 -593354 -326446 -648392 -755408 -326951 -948594 -366828 -550468 -787349 -352026 -237985 -536486 -346235 -768331 -705789 -524397 -479157 -778156 -966821 -48326 -479076 -463290 -704934 -721914 -614898 -121616 -512396 -714780 …
Output: 837

Constraints:

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

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