CT931

Nils Counts the crates

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Legend says the vault under the shale slopes of Greystone opens only for a perfect tally of crates. Nils means to find out. 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 <= 30; -100 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 17 834224 301135 776052 940227 582726 193880 460870 645878 235492 443662 927313 636670 887649 47060 731522 455887 912080
Output: 840589

Example 2:

Input: 19 391569 731510 94722 2276 524577 334864 868711 602673 607084 488653 723466 133153 74193 911110 358541 574392 716072 722343 760010
Output: 836917

Example 3:

Input: 7 474871 318053 615889 885663 655037 623554 791431
Output: 297836

Constraints:

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

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