CT25151

The Zigzag Stretch of Tuskmore

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The surveyor Captain has been asked to win the guild's seasonal contest. On the desk lies a long table of ribbons readings. 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 <= 945; -1000000 <= a[i] <= 1000.

Example 1:

Input: 221 -273668 -466809 -853877 -204387 -949167 -700115 -563080 -928840 -681876 -362378 -450297 -894493 -456390 -405776 -308555 -198064 -178066 -626273 -319876 -755392 -802601 -721057 -991278 -306379 -407230 -227141 -211079 -405124 -844126 -182440 -669478 -409186 -657718 -669204 -538393 -932964 -740515 -303317 -523060 -686264 -744223 -306967 -492038 -62058 -251974 -746659 -968659 -216004 -471126 -441883 -884625 -1614 -369366 -636891 -164956 -641534 -843611 -123862 -950200 -364635 -23168 -382696 -826927 -397356 -34154 -589867 -480697 -690993 -761151 -196466 -845146 -559749 -58406 -858379 -758617 -250555 -328565 -940004 -662989 -583477 -647697 -333361 -757823 -271773 -626706 -406492 -715294 -733441 -133624 -852781 -958280 -737595 -998577 -885758 -550821 -119554 -810741 -964198 -449283 -444444 -3…
Output: 221

Example 2:

Input: 34 -597112 -875516 -745463 -904 -143247 -208614 -580589 -638192 -171204 -277282 -12901 -850949 -495993 -590883 -393997 -779938 -849714 -134373 -271448 -410485 -731579 -327232 -608116 -287133 -817658 -525265 -293180 -961028 -45529 -539972 -255123 -271956 -494052 -936925
Output: 34

Example 3:

Input: 927 -739886 -136208 -691611 -212829 -132159 -986239 -288065 -796122 -511761 -342816 -665856 -170202 -202759 -40245 -977351 -475369 -912752 -667762 -290708 -12145 -990027 -527500 -369540 -608903 -3277 -711234 -581438 -172485 -38694 -432924 -35058 -489157 -498542 -39078 -234956 -141399 -9182 -378558 -549210 -135462 -46993 -752036 -803829 -428709 -420435 -334932 -749117 -319195 -734525 -251160 -228280 -184122 -37284 -977899 -393303 -373165 -785916 -979887 -910497 -678525 -487816 -706100 -854217 -665684 -841760 -388309 -926491 -619969 -76379 -146417 -599085 -455575 -212475 -45910 -660260 -108758 -140529 -754108 -868847 -309503 -463673 -481624 -888295 -990497 -67257 -322915 -799709 -967516 -664084 -267758 -809753 -786694 -593672 -82007 -475616 -9032 -242135 -777805 -425157 -202044 -589300 -1503…
Output: 927

Constraints:

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

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