CT26619

Ravi's scrolls Reckoning

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Caravans arrive at the trading post of Goldmeadow with crates of scrolls, and Ravi the chronicler must account for every last one. Task: Read n integers and print the largest absolute difference between two consecutive elements. For n=1 print 0. Input format: First line: n. Second line: n space-separated integers. Output format: Print the maximum consecutive absolute difference. Constraints: 1 <= n <= 935; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 162 -911568 -728412 -474593 -993022 -700751 -300278 -865860 -561510 -577703 -420580 -521315 -366852 -309070 -111806 -143872 -825246 -135300 -307465 -622778 -225086 -757944 -334363 -249682 -243559 -450156 -595573 -467974 -663463 -981701 -495219 -234347 -881456 -504765 -540441 -749970 -924588 -9282 -470470 -809218 -451102 -793425 -166638 -935397 -577792 -743125 -176256 -301328 -117433 -415854 -577189 -691525 -681638 -144237 -944140 -779789 -852693 -777787 -171619 -592152 -870357 -599305 -516706 -747389 -54252 -781224 -346172 -277556 -929140 -235819 -278880 -683653 -592439 -489747 -375985 -82193 -640643 -51371 -372774 -925431 -812341 -523908 -143621 -691647 -886895 -571972 -276302 -603824 -296064 -241120 -199376 -27476 -807024 -325441 -17933 -79479 -490967 -666423 -657213 -459297 -398084 -129003 -164280 -55277 -775976 -183018 -644474 -142021 -875235 -549649 -415296 -242359 -918792 -547188 -138597 -590366 -814448 -798668 -593958 -768738 -138605 -581184 -703044 -876398 -332372 -313864 -298843 -794726 -224449 -538720 -620040 -962549 -954500 -451867 -676715 -91669 -972105 -729822 -156087 -477678 -85071 -179110 -531660 -276194 -583300 -948261 -150542 -797170 -947689 -947344 -818697 -909749 -834401 -494996 -81958 -682261 -325078 -407984 -679200 -439651 -117273 -876695 -408172
Output: 915306

Example 2:

Input: 348 -216966 -351821 -119627 -253649 -436679 -439165 -592086 -906668 -720872 -475460 -867707 -883737 -30612 -852501 -46027 -90680 -61871 -598880 -259292 -364916 -99217 -503433 -57935 -671680 -970705 -340467 -7195 -377725 -21317 -696435 -134825 -969145 -628513 -311128 -979764 -651860 -994964 -526751 -72976 -715871 -119778 -574394 -718719 -365097 -370476 -679774 -87301 -480266 -669652 -903836 -339103 -753750 -169649 -127343 -673412 -699239 -454849 -16752 -211455 -837487 -467411 -93211 -813916 -522514 -895898 -69280 -3475 -229216 -802720 -487339 -865945 -450847 -960325 -412320 -878009 -139647 -165492 -542899 -803604 -247512 -746716 -801250 -309234 -431006 -891285 -629268 -528744 -63187 -814295 -628922 -824684 -960621 -113280 -998266 -130233 -657264 -55991 -308854 -894447 -863426 -402352 -983942 -411931 -467066 -946682 -456956 -833302 -619264 -289485 -328382 -582328 -573407 -160838 -918709 -688291 -754847 -282805 -828586 -462597 -579684 -127727 -778844 -148297 -836884 -454942 -713827 -881514 -152968 -410880 -53015 -586144 -154787 -607633 -263930 -249881 -751770 -297926 -564006 -477313 -255652 -642864 -197451 -721225 -803162 -121428 -999135 -842493 -912373 -487796 -437676 -239684 -326210 -208619 -637141 -849527 -346636 -903016 -362233 -32412 -496977 -129720 -889049 -746183 -273771 -166032 -489271 -828962 -427652 -919253 -553623 -956703 -489723 -818662 -931574 -59973 -872647 -659458 -634044 -439666 -130624 -686683 -651066 -347878 -275183 -635473 -644338 -401038 -209642 -611212 -969997 -947799 -375994 -967579 -157238 -550065 -590119 -419965 -779555 -60482 -643744 -968820 -568455 -88079 -372628 -178515 -572784 -809713 -450295 -884909 -108366 -272419 -946617 -304977 -319635 -344946 -477576 -223236 -154011 -296319 -122727 -21848 -240213 -115540 -94503 -289216 -951521 -28558 -648937 -796596 -85972 -518256 -163860 -302016 -368631 -906770 -450709 -260702 -520083 -453218 -213010 -170284 -247033 -155797 -488690 -852709 -68930 -195563 -789136 -461062 -899200 -316359 -311687 -689648 -849503 -922786 -921926 -512577 -678030 -864536 -720048 -565262 -930254 -321704 -889162 -486751 -920346 -508258 -154228 -745957 -31868 -222438 -908884 -625955 -968393 -496235 -449375 -106681 -763176 -78272 -129399 -771957 -594721 -737203 -68451 -536827 -581247 -921861 -751570 -553796 -777239 -73727 -664280 -910895 -380685 -932771 -312965 -547111 -166167 -254104 -803823 -562127 -172741 -960572 -377174 -64144 -35897 -675423 -974511 -716239 -23223 -685839 -672927 -465517 -498946 -741727 -888428 -16657 -336379 -832150 -574443 -855195 -145098 -815739 -699434 -706556 -555555 -808158 -517565 -408611 -235109 -233837 -339348 -782034 -266747 -571750 -221803 -579796 -615353 -612369 -70749 -581051 -239112 -393008 -80568 -250292 -599194 -880703 -261642
Output: 922963

Example 3:

Input: 215 -865112 -792535 -132020 -920815 -857558 -433801 -639734 -408485 -431458 -709391 -568761 -46665 -206050 -946588 -195261 -741504 -882688 -664476 -87894 -351510 -906523 -774819 -8387 -165842 -635806 -818464 -475825 -694690 -945580 -710959 -479837 -764732 -47989 -423074 -902036 -254156 -998277 -775572 -379019 -228863 -625969 -594067 -914082 -651132 -446627 -428042 -761333 -591781 -121934 -714968 -466449 -424565 -868172 -737459 -325610 -373292 -616405 -991830 -603611 -678451 -602985 -983133 -560270 -732666 -991890 -611672 -703301 -830708 -142878 -260127 -215028 -902646 -708239 -140824 -800158 -108587 -723892 -130767 -840914 -72992 -599391 -672718 -54542 -89771 -541812 -890395 -897519 -215352 -289938 -351883 -270107 -119456 -311528 -152436 -503056 -879645 -983549 -473893 -343060 -864280 -590460 -339594 -741783 -121048 -849781 -201402 -966030 -143229 -369902 -781692 -459874 -405407 -663238 -912649 -343902 -73105 -554660 -340458 -483468 -308397 -89268 -165889 -559882 -724464 -745747 -959265 -708557 -348636 -635016 -714937 -602706 -376981 -271197 -412741 -568767 -29993 -480001 -585799 -965293 -68614 -557212 -892529 -886359 -921921 -846222 -384755 -836951 -755757 -822683 -185422 -711424 -812500 -507012 -342488 -848483 -29926 -479357 -966959 -115603 -773219 -672788 -750178 -750638 -525329 -522440 -89422 -353816 -349328 -610395 -551429 -15142 -338619 -477483 -941433 -390488 -127946 -264543 -652398 -496567 -41342 -147059 -862083 -164065 -980003 -592377 -472656 -270335 -886035 -117274 -469172 -784426 -960966 -279015 -624747 -573108 -959373 -864601 -826460 -907203 -330895 -634867 -217655 -61481 -272702 -768640 -725756 -975592 -673233 -77825 -89986 -881561 -979896 -647317 -574311 -675529
Output: 896679

Constraints:

1 <= n <= 935; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Loading...
Test Cases:No test cases
No test cases available.
Ravi's scrolls Reckoning - EASY Coding Problem | CodeTikki