CT1229

Zigzag crates Widest Spread

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Deep in the lantern reef of Glowtide, Jaya studies rows of crates entries. One clean number will settle the guild's oldest argument. Task: Read n integers and print the difference between the largest and smallest. Input format: First line: n. Second line: n space-separated integers. Output format: Print max(a) - min(a). Constraints: 1 <= n <= 30; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 23 -628381 -113592 -146348 -882760 -308424 -338449 -847414 -98065 -749492 -778590 -870479 -397748 -287979 -815961 -290026 -473209 -921530 -568350 -32414 -581194 -793674 -252624 -642472
Output: 889116

Example 2:

Input: 14 -139974 -530159 -706013 -351724 -592615 -560918 -846461 -994538 -868197 -841824 -609365 -475693 -345170 -232958
Output: 854564

Example 3:

Input: 18 -638483 -905789 -656097 -629791 -748568 -223646 -879781 -537986 -969059 -306898 -868081 -81180 -207566 -377726 -392650 -882254 -974149 -13646
Output: 960503

Constraints:

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

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