CT30705

Kael's Zigzag Stretch Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Kael the inventory keeper watches over the rookery of Crowhaven's stores of panels. A careful computation stands between order and chaos. 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 <= 2482; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1311 -146264 -368944 -261895 -434889 -490125 -379747 -577665 -301977 -100722 -214249 -390691 -74808 -806663 -13856 -793700 -377361 -62184 -82034 -315160 -9143 -551244 -42067 -744992 -455306 -505870 -349820 -37905 -705619 -733386 -332201 -798120 -968166 -11135 -27650 -480490 -353753 -446458 -112721 -868409 -51458 -50968 -487290 -640069 -717645 -944314 -468247 -326550 -891719 -806579 -559817 -142409 -580216 -512131 -213552 -707810 -440196 -403877 -326989 -74599 -664598 -224371 -823536 -409536 -888065 -732130 -741305 -930524 -303387 -104470 -390424 -884063 -262915 -296669 -781562 -211286 -822776 -533004 -762735 -596311 -141913 -757242 -781244 -33218 -602224 -917764 -627463 -657446 -371355 -407094 -590868 -401685 -533727 -512936 -277914 -990170 -303984 -663504 -520912 -420675 -468515 -232239 -…
Output: 1311

Example 2:

Input: 394 -99215 -947488 -673889 -976985 -298179 -849135 -212678 -17587 -803430 -779826 -407498 -98812 -672903 -12903 -578474 -706131 -934891 -637773 -340216 -395250 -481728 -533238 -508110 -216927 -717488 -959690 -330620 -409891 -857888 -844364 -826678 -648906 -132405 -882236 -54476 -408581 -91652 -218729 -710378 -613508 -114020 -793824 -265126 -508671 -617031 -767228 -615764 -359056 -852196 -798200 -741948 -862171 -51818 -4724 -986206 -21202 -224550 -963394 -302464 -629977 -266215 -573530 -595633 -70180 -398152 -288440 -262659 -321009 -189641 -868558 -414172 -834072 -951575 -309821 -489479 -107212 -407296 -829871 -980619 -389641 -783037 -447781 -483653 -944842 -164301 -922950 -292449 -774226 -618126 -452039 -403782 -143306 -86020 -752063 -813353 -807004 -870591 -955904 -950566 -960278 -455753 …
Output: 394

Example 3:

Input: 1170 -248043 -53776 -235954 -380131 -394627 -449550 -28456 -178367 -250496 -68795 -189918 -634609 -96134 -547373 -710861 -32011 -493735 -830995 -316996 -652657 -838646 -667866 -603737 -447291 -163512 -185289 -719603 -320079 -582407 -953600 -546662 -991543 -563329 -835635 -203907 -691469 -123749 -861164 -812731 -80760 -875270 -653396 -876745 -389210 -697600 -99229 -296704 -185052 -157316 -376930 -718605 -496960 -897324 -301095 -429858 -846881 -778951 -53976 -392876 -634355 -698226 -201440 -803143 -326136 -859593 -255524 -896672 -429567 -428201 -635868 -677554 -682235 -18437 -926268 -669713 -979198 -985129 -407582 -834718 -231627 -605351 -465124 -134847 -777339 -353009 -402050 -554074 -194679 -652117 -158956 -444104 -113157 -88596 -862341 -261980 -824986 -955699 -236947 -365782 -214809 -3590…
Output: 1170

Constraints:

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

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