CT635

Ulrica and the Widest Spread

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Ulrica found an old ledger of lanterns in the shed attic at the wren hedges of Thimblewick. The margin notes pose a precise question. 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 <= 36; -100 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 22 817 240 517 824 758 808 341 122 131 795 -7 939 905 459 883 21 146 337 301 243 861 841
Output: 946

Example 2:

Input: 18 171 958 -32 723 933 655 233 515 662 40 503 641 956 793 43 10 825 811
Output: 990

Example 3:

Input: 36 615 950 943 719 377 103 438 -19 705 299 414 -3 472 346 370 70 76 94 484 767 -2 910 -66 443 6 161 919 71 986 -78 475 739 785 406 398 805
Output: 1064

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Ulrica and the Widest Spread - EASY Coding Problem | CodeTikki