Time limit: 3.0s
Memory limit: 64M
You are given numbers, . Output the range of this list. The range of a list of numbers is the difference between the largest and smallest values in this list.
In all tests,
The first line contains one number, .
The second line contains spaced integers, , the numbers in this list.
On one line, output the range of the numbers.
10 9 2 9 6 8 7 1 3 9 6
How do you split the numbers? Sorry, I am really new to this. Thanks!
Since you seem to be a python user, you can do the following:
This comment is hidden due to too much negative feedback. Show it anyway.
How do you shorten the memory limit, I can't get lower than 64M, C#
Arrays are not required to complete the problem
The main issue is not about arrays, but rather the length of the input. The entire line is read as a string, which is fairly large (around 12 million characters long) and since this string is probably copied a few times, this can easily go over the memory limit (at the time of this post, it is 64MB). The solution is to not actually read the entire string in the input. This can be done with
Console.Read()which only reads a single character at a time. You will then have to parse the characters into integers yourself.