CT26457

The windows at Keelwind

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The harbor bell rings at the shipyard of Keelwind; Mina weighs the day's windows manifests and starts the calculations. 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 <= 1678; -1000000 <= a[i] <= 1000.

Example 1:

Input: 576 -673075 -350337 -432449 -243544 -522425 -443734 -722027 -975199 -320409 -879239 -766429 -106834 -980324 -54662 -460566 -466597 -261457 -416076 -439674 -394011 -331002 -521536 -81304 -956521 -486992 -38393 -575450 -786986 -769517 -897168 -138551 -720933 -732225 -462899 -249421 -715672 -26171 -541481 -586125 -856848 -502265 -150584 -748976 -669212 -624980 -152969 -529901 -599904 -243207 -8017 -481085 -179862 -95599 -641785 -67715 -477913 -728271 -175487 -488520 -997715 -267164 -470443 -748043 -79981 -775116 -958737 -586471 -425668 -293702 -568252 -819282 -653950 -565099 -621313 -717539 -241652 -207893 -950525 -871318 -930541 -702411 -710574 -834193 -441610 -684356 -337088 -404955 -582553 -963036 -99965 -438754 -11828 -783252 -738391 -991242 -461363 -550096 -468980 -42025 -783793 -569019 …
Output: 576

Example 2:

Input: 204 -794127 -626983 -842178 -218804 -553590 -245471 -503422 -74166 -809030 -684633 -616653 -1114 -195109 -50779 -900814 -594566 -732610 -592804 -953344 -743536 -285155 -120372 -26458 -322264 -845797 -772967 -478626 -424379 -312180 -60457 -30507 -321842 -431918 -317830 -952938 -356697 -720052 -275297 -820495 -432966 -359076 -258974 -57586 -745185 -66788 -546786 -19565 -78843 -745617 -359798 -515806 -701227 -709708 -868063 -430661 -327964 -140374 -819247 -809755 -912830 -953032 -51111 -149854 -800234 -257291 -666981 -333026 -777347 -893891 -46986 -112496 -896339 -174418 -128199 -696598 -395877 -606113 -178949 -438803 -491399 -851167 -662968 -360457 -482954 -129525 -389414 -223351 -344841 -630531 -471364 -775598 -732473 -223751 -329136 -270752 -455230 -230320 -283862 -587031 -81608 -480070 -4…
Output: 204

Example 3:

Input: 572 -242852 -460384 -723026 -968930 -922170 -337867 -161964 -645808 -106711 -968298 -75990 -723968 -50495 -800999 -679823 -757306 -42405 -480562 -583039 -132771 -783280 -340358 -867924 -855667 -802500 -235220 -980478 -680620 -930461 -602749 -139276 -138250 -693311 -479676 -221979 -337414 -610974 -119671 -417427 -733389 -202229 -19784 -735562 -258564 -925292 -487629 -507277 -364311 -990916 -782274 -578539 -514536 -659245 -753097 -625289 -848981 -993548 -972314 -478268 -827507 -969303 -398484 -444790 -786857 -897278 -587718 -762510 -964567 -425130 -291953 -512208 -779653 -499775 -635903 -347096 -821265 -146300 -162195 -69372 -52170 -835372 -634201 -180871 -352809 -182782 -820715 -600649 -566182 -158104 -883983 -751852 -942318 -261554 -230050 -991185 -934393 -976683 -988602 -441324 -126695 -3…
Output: 572

Constraints:

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

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