#C1650. Growing Trees
Growing Trees
Growing Trees
You are given a number of test cases. In each test case, you are given an integer \(n\) representing the number of trees, followed by \(n\) integers which denote the initial heights of the trees.
The task is to determine the minimum number of days required for all trees to be at least as tall as the tallest tree at the beginning. Since only the shortest tree grows until it reaches the height of the initially tallest tree, the answer is given by the formula:
$$days = \max(heights) - \min(heights)$$
Read the input from standard input (STDIN) and print the result for each test case on a new line to standard output (STDOUT).
inputFormat
The first line contains an integer \(T\) representing the number of test cases. Each test case consists of two lines:
- The first line contains an integer \(n\) --- the number of trees.
- The second line contains \(n\) space-separated integers representing the initial heights of the trees.
For example:
5 3 2 3 1 4 1 2 2 1 5 5 5 5 5 5 3 5 3 1 2 8 3
outputFormat
For each test case, output a single line with the minimum number of days required.
For the sample input above, the correct output is:
2 1 0 4 5## sample
1
3
2 3 1
2
</p>