CT31310

The windows at Whitesnow

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Xavi runs the granary at the tundra station of Whitesnow. Today the books show a list of windows, and the numbers must be worked out before sundown. 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 <= 2857; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 2205 -569073 -567765 -60276 -285476 -394101 -356623 -918128 -102276 -646009 -990181 -900909 -242656 -831619 -946663 -867081 -349355 -669994 -655913 -226531 -278177 -550151 -580616 -67512 -688445 -766760 -340807 -510627 -872486 -824811 -94076 -287320 -329145 -385148 -796025 -587820 -431782 -301116 -429110 -106209 -34676 -673666 -628357 -3234 -875094 -141998 -365951 -297088 -162471 -875370 -684465 -154386 -282231 -691829 -133797 -978529 -167644 -655830 -949800 -952617 -311841 -629489 -630186 -160877 -883462 -644151 -665433 -225184 -506811 -459963 -964750 -662406 -710756 -765551 -39079 -460806 -56689 -874895 -63948 -214592 -424964 -387202 -434012 -714942 -795996 -86956 -78991 -283781 -409994 -672417 -432669 -11521 -451495 -50672 -803275 -382715 -25146 -221072 -49223 -823429 -32425 -345105 -17…
Output: 2205

Example 2:

Input: 2846 -725454 -984139 -92700 -628571 -609825 -852808 -939661 -430504 -663235 -968483 -96115 -462303 -656355 -754389 -435233 -685713 -281281 -946312 -82216 -490834 -865773 -695825 -362985 -803240 -78981 -128298 -986241 -270692 -694298 -656771 -322823 -302618 -752814 -564918 -388434 -737864 -866201 -600502 -835019 -66638 -176132 -895042 -157135 -158128 -468866 -564933 -518679 -993361 -42887 -561524 -342598 -614464 -377520 -317246 -785757 -567763 -119968 -112802 -937322 -758874 -101864 -89241 -733642 -160982 -509523 -535308 -2850 -943203 -328700 -398770 -870356 -222035 -992970 -572934 -354969 -319202 -84449 -836884 -650217 -288522 -710282 -704191 -115295 -85847 -108150 -547937 -3960 -696194 -679485 -680237 -683234 -32985 -639345 -25753 -385570 -992459 -993799 -121955 -386755 -600420 -148192 -6…
Output: 2846

Example 3:

Input: 1196 -755196 -483208 -888566 -493783 -740903 -18127 -290781 -115389 -208170 -164186 -129479 -333565 -597872 -482764 -131254 -417684 -880141 -637898 -727195 -132423 -940901 -288338 -984301 -661239 -371481 -773660 -318965 -94514 -378268 -713668 -966153 -158920 -890235 -743157 -2922 -862030 -346320 -373497 -986519 -787071 -269366 -165994 -175040 -229324 -868441 -106871 -933189 -73719 -924745 -562951 -882343 -795226 -867410 -807773 -160951 -258664 -300622 -856404 -776062 -453743 -520961 -1903 -839004 -666039 -111458 -226706 -596181 -848454 -752989 -316279 -899241 -696651 -500469 -567613 -911391 -803788 -921207 -885216 -9905 -80571 -72509 -753796 -568922 -340430 -202169 -828754 -453288 -610718 -315956 -106430 -968596 -190306 -197544 -914782 -486014 -593444 -772737 -511760 -614655 -937775 -53051…
Output: 1196

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The windows at Whitesnow - MEDIUM Coding Problem | CodeTikki