CT29558

The Twilight segments of Nandini

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the bamboo terraces of Verdantstep as Nandini unrolls the day's manifest of segments. The tally will decide the next shipment. 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 <= 3926; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1500 -583431 -732711 -252552 -315260 -585621 -581915 -484897 -803778 -141384 -7851 -934881 -293156 -126200 -440176 -439269 -190032 -142472 -332452 -41495 -445880 -940651 -337081 -429516 -45691 -477037 -652703 -929025 -200468 -792555 -911726 -412108 -297901 -546693 -408595 -814283 -335239 -188429 -369736 -348824 -367395 -581324 -144855 -515829 -529249 -707149 -505361 -365561 -515082 -863927 -677012 -367031 -954564 -133387 -705565 -179810 -178689 -482584 -338372 -96283 -910264 -2856 -826962 -10929 -25889 -769921 -358902 -206824 -258296 -323307 -803128 -894785 -958250 -545810 -986641 -790248 -366648 -927847 -725559 -4678 -215141 -625501 -218797 -546576 -679269 -976634 -597143 -121550 -881052 -806830 -298928 -233435 -643744 -828435 -737562 -202253 -850374 -889580 -104585 -210847 -574519 -30852…
Output: 1500

Example 2:

Input: 2944 -537985 -932608 -908983 -967199 -312679 -279808 -918479 -109014 -248273 -828456 -480002 -275967 -815911 -783244 -88106 -747439 -467655 -866631 -274441 -967965 -659570 -475640 -624113 -449409 -669114 -884905 -464060 -852746 -224222 -421926 -219196 -536608 -783403 -221607 -356633 -2007 -650491 -93423 -316061 -150995 -245273 -864431 -693719 -663154 -151191 -716293 -445216 -126190 -252687 -805307 -976176 -139124 -421237 -490548 -202068 -510621 -602634 -974553 -412324 -722093 -823953 -82616 -261235 -610649 -765773 -218130 -344454 -721843 -592678 -112191 -916096 -698786 -877422 -772735 -97708 -459561 -368909 -493993 -432909 -781683 -375061 -86684 -29810 -484950 -25356 -374960 -874296 -114458 -109637 -390037 -858386 -977962 -465244 -723791 -796907 -507841 -635481 -77980 -524745 -348079 -5839…
Output: 2944

Example 3:

Input: 2448 -164248 -865485 -975220 -628695 -295182 -81399 -101788 -201873 -969366 -656955 -955578 -130986 -167260 -22828 -997241 -116675 -23375 -450396 -608904 -499013 -465593 -403456 -727479 -230377 -318532 -718244 -844743 -536134 -41877 -657281 -686457 -830020 -613708 -89720 -761728 -595547 -879558 -41401 -614507 -486133 -541428 -67806 -127837 -266520 -911397 -916725 -964116 -799640 -809307 -251003 -655980 -8468 -363628 -806371 -331350 -864643 -454881 -249754 -19949 -951644 -324324 -15721 -339595 -936878 -706409 -331062 -414156 -772250 -490712 -894461 -221029 -639068 -440288 -955623 -753252 -683633 -692074 -150648 -685213 -707179 -719293 -316899 -889180 -788901 -796567 -171630 -133846 -920840 -98222 -935222 -356507 -731558 -536944 -787862 -174719 -621977 -289769 -66113 -131829 -53766 -599184 -…
Output: 2448

Constraints:

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

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