CT1761

Ivan's Largest Step Ledger

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Ivan found an old ledger of barrels in the bakery attic at the desert outpost of Sandspire. The margin notes pose a precise question. 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 <= 83; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 20 -845067 -268118 -499039 -637695 -6575 -702275 -766001 -834405 -952584 -940423 -70778 -690932 -341219 -326180 -459846 -576048 -787180 -745388 -79779 -951925
Output: 872146

Example 2:

Input: 3 -913329 -373280 -808381
Output: 540049

Example 3:

Input: 9 -768344 -266970 -235667 -86840 -95221 -460286 -175247 -995907 -492113
Output: 820660

Constraints:

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

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