CT29641

Last panels of Dante

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the forest village of Briarthorn, Dante studies rows of panels entries. One clean number will settle the guild's oldest argument. 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 <= 1196; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 738 -642563 -569842 -186493 -848600 -37995 -881716 -264380 -626743 -619328 -97493 -163510 -303412 -976958 -401932 -581689 -477821 -735621 -486686 -529151 -29525 -546709 -346249 -726530 -8684 -140260 -233067 -275788 -363517 -223994 -686143 -462692 -457115 -607340 -707119 -450369 -536791 -114588 -505012 -221012 -872579 -987885 -527726 -267732 -653959 -27890 -513223 -692618 -249242 -277528 -984948 -6375 -792176 -821953 -688839 -834243 -635438 -75017 -959177 -416257 -559498 -935272 -29697 -61676 -413197 -36465 -132942 -415024 -217341 -656984 -96462 -164667 -449003 -112123 -409074 -567972 -778846 -669691 -230904 -259998 -764965 -379114 -418651 -842108 -300356 -244733 -126902 -653987 -892105 -954707 -349026 -507016 -789634 -951789 -638388 -170891 -517287 -709316 -104713 -593789 -31980 -879774 -4…
Output: 738

Example 2:

Input: 849 -157825 -905769 -951033 -194654 -848052 -496144 -504595 -490906 -182631 -692603 -970349 -632108 -593011 -111260 -401264 -253087 -790485 -443774 -653308 -868616 -840826 -668830 -651717 -538605 -958806 -395460 -471470 -497046 -628028 -14613 -866730 -946348 -448305 -972742 -420641 -251359 -982253 -314608 -818984 -552727 -707890 -435219 -310901 -148956 -719868 -986501 -468501 -25453 -981449 -730765 -336611 -147227 -329026 -50088 -119148 -612345 -489324 -950443 -812143 -754380 -725455 -421208 -597177 -812599 -277029 -498785 -154711 -792423 -960774 -659584 -54913 -189778 -137806 -348659 -991402 -686415 -137262 -925404 -360093 -302674 -133229 -170235 -389296 -157328 -469664 -701301 -902491 -627042 -262414 -450034 -370710 -195450 -421049 -259267 -186851 -905427 -578946 -812225 -7399 -896433 -1…
Output: 849

Example 3:

Input: 124 -37399 -708996 -768967 -520775 -598061 -233579 -903946 -264791 -528066 -403505 -278371 -362391 -463261 -198308 -780435 -353886 -18967 -218222 -706822 -365468 -70516 -641528 -215154 -151762 -870854 -112019 -711794 -704746 -506110 -111316 -346215 -17469 -759317 -500111 -458318 -116015 -838893 -216364 -634007 -960565 -404879 -91536 -175233 -709436 -933456 -816376 -449283 -906885 -983974 -308156 -538382 -992279 -429642 -382878 -352728 -483220 -983034 -381284 -990931 -236163 -897877 -493435 -654367 -200862 -36766 -827578 -869409 -955433 -449582 -105431 -739347 -556768 -882112 -597614 -325566 -895970 -12294 -297125 -113897 -907034 -704867 -797840 -42624 -790850 -523798 -743269 -67596 -947342 -273122 -930839 -571427 -774897 -638825 -572017 -749339 -723282 -191989 -851583 -656247 -343026 -4373…
Output: 124

Constraints:

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

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