CT34806

The Zigzag Stretch of the Caramel windows

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the beacon hill of Lantern Tor close for winter, Freya must finish the windows ledger - one figure at a time. 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 <= 1417; -1000000 <= a[i] <= 1000.

Example 1:

Input: 204 -168599 -19338 -276177 -744415 -666716 -561420 -119192 -959469 -767468 -624521 -842673 -285092 -964664 -468505 -358867 -887391 -965262 -152134 -333782 -76151 -244938 -27101 -788827 -136845 -60717 -43334 -457616 -761974 -778872 -828108 -955034 -662862 -69349 -21362 -575483 -794150 -216140 -527188 -987932 -664332 -869223 -92096 -283651 -510249 -602207 -753393 -97256 -889900 -215439 -539149 -336058 -355239 -27792 -43275 -253252 -127862 -113105 -40819 -82703 -531001 -664983 -571847 -890287 -770429 -706987 -462262 -738649 -651108 -969096 -116688 -809826 -924729 -759589 -58476 -415105 -631746 -594199 -732332 -354469 -491331 -752508 -875148 -539388 -2974 -228600 -399660 -336785 -551020 -962314 -907035 -476103 -659646 -434316 -259818 -277348 -981073 -57911 -749571 -578596 -185989 -120783 -3052…
Output: 204

Example 2:

Input: 790 -710494 -882889 -438636 -287721 -299241 -143709 -378973 -560486 -173929 -755058 -562604 -289405 -361116 -335655 -535479 -439351 -841498 -50869 -282183 -579804 -535680 -751419 -350114 -393163 -79232 -405997 -527514 -617119 -258550 -70311 -995044 -612406 -637520 -804877 -560881 -414996 -558902 -963188 -467579 -535636 -389377 -551462 -175538 -81129 -55557 -383343 -625979 -856568 -49279 -481397 -840375 -65712 -353744 -462340 -585305 -937260 -652105 -289534 -162385 -393283 -766409 -23853 -252354 -888560 -673183 -85058 -754695 -185056 -58052 -452091 -117988 -303106 -677179 -576459 -881813 -659410 -278771 -708783 -691200 -246539 -29372 -464382 -841280 -251587 -963151 -344834 -914141 -220472 -564465 -425847 -641626 -945812 -448898 -524768 -445694 -849335 -856157 -971054 -968422 -560675 -40828 …
Output: 790

Example 3:

Input: 366 -659590 -238844 -361645 -745749 -226732 -971381 -430030 -645184 -821549 -213077 -380077 -686043 -41337 -222816 -356902 -43416 -298623 -246157 -408818 -742439 -861723 -184247 -724379 -88249 -550395 -241849 -132074 -494057 -164460 -108781 -5173 -569669 -346317 -618956 -97927 -387028 -491739 -837922 -627749 -584281 -536750 -43119 -92971 -799967 -894557 -604675 -469424 -958930 -860336 -353660 -446854 -615750 -479513 -740837 -482284 -281907 -460066 -388529 -697747 -393711 -941479 -392347 -779672 -435996 -139784 -159549 -44143 -147683 -918508 -723635 -519662 -755889 -14110 -333189 -955353 -751422 -240499 -252007 -98714 -336214 -587874 -878625 -866763 -89143 -898677 -854352 -436243 -751522 -322089 -592021 -343828 -483918 -44808 -399168 -499783 -494688 -732640 -626965 -441220 -383399 -513741 -…
Output: 366

Constraints:

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

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