CT28047

Pia's windows Reckoning

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the river town of Willowford opens only for a perfect tally of windows. Pia means to find out. 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 <= 801; -1000000 <= a[i] <= 1000.

Example 1:

Input: 162 -742682 -478519 -96113 -505125 -976058 -512986 -651910 -935707 -501497 -29507 -354951 -967608 -825462 -36901 -548871 -433029 -235363 -634755 -737239 -641545 -41463 -421309 -525088 -338577 -18557 -794418 -572623 -635827 -888700 -651136 -593198 -915924 -678141 -940676 -539166 -1027 -25971 -65287 -605914 -562298 -536155 -781357 -56734 -121177 -84651 -836019 -725427 -180275 -762337 -654542 -729502 -735224 -404494 -815341 -570450 -816213 -249072 -312590 -878673 -235142 -417196 -615008 -84520 -18731 -512873 -282002 -933719 -620917 -463134 -346841 -435071 -845146 -251902 -903280 -584138 -684762 -511531 -883021 -948362 -782872 -669333 -992401 -802856 -388451 -63338 -945313 -6749 -427111 -198809 -372389 -776418 -352351 -702761 -393959 -119138 -7056 -823810 -379675 -741604 -624768 -653557 -40608…
Output: 162

Example 2:

Input: 727 -452288 -72414 -610343 -6482 -960216 -478742 -136501 -625948 -785151 -934157 -561989 -82036 -791769 -16747 -153450 -943901 -723135 -260859 -647115 -549985 -890261 -55894 -294720 -207270 -725599 -523894 -408130 -269559 -30834 -137881 -109210 -915966 -729931 -26133 -427173 -61421 -584190 -452964 -627195 -270465 -238201 -346143 -290847 -648754 -789178 -254025 -687442 -698141 -873058 -40994 -919117 -953196 -48667 -390016 -625493 -890629 -870574 -463000 -194663 -858195 -455970 -732354 -947023 -169875 -585849 -226874 -149303 -154769 -317551 -525414 -646865 -805420 -611333 -325989 -89008 -940589 -720027 -617164 -157444 -222036 -698468 -902679 -29270 -327645 -940717 -816766 -524362 -539251 -80011 -256967 -102400 -703223 -273667 -37640 -64156 -368994 -471218 -488758 -316362 -92741 -98698 -72665…
Output: 727

Example 3:

Input: 381 -725257 -83767 -972902 -239121 -11077 -493302 -531089 -16332 -2987 -561711 -329617 -676272 -827900 -757884 -606615 -766004 -159529 -591748 -736434 -483564 -816928 -678362 -907574 -353598 -778057 -812020 -863420 -840852 -579674 -602213 -439334 -920906 -714615 -490706 -459721 -608526 -648624 -602671 -682426 -106894 -113655 -507727 -549886 -100176 -918181 -674585 -791351 -802711 -478754 -472296 -185448 -303710 -313062 -943138 -459021 -898512 -67955 -816410 -844474 -562241 -633505 -444789 -70314 -985365 -816252 -382359 -996050 -909562 -748355 -281991 -823454 -222452 -891827 -892732 -10559 -862197 -340073 -302879 -777499 -648256 -827230 -785054 -192063 -180330 -651160 -553672 -497709 -114084 -166815 -695862 -352438 -581576 -380327 -20219 -353025 -28537 -348359 -683631 -21541 -851898 -979764…
Output: 381

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Pia's windows Reckoning - EASY Coding Problem | CodeTikki