#K34282. Tallest Tree Growth
Tallest Tree Growth
Tallest Tree Growth
Given \(P\) test cases, each test case describes several types of trees. For each test case you are provided with:
- An integer \(T\) representing the number of tree types.
- A list of \(T\) integers representing the growth rates for each tree type.
- An integer \(Y\) representing the number of year intervals.
- A list of \(Y\) integers representing the year intervals.
Your task is to calculate, for each year interval in a test case, the height of the tallest tree. The tallest tree in a test case is the one with the maximum growth rate. Its height after \(y\) years is given by:
[ \text{height} = \text{max}(growth\ rates) \times y ]
Print the result for each test case on a new line, with the values separated by a single space.
inputFormat
The input is read from standard input (stdin) and has the following format:
P T growth_rate_1 growth_rate_2 ... growth_rate_T Y year_1 year_2 ... year_Y ... (repeated for each test case)
Where:
- P is the number of test cases.
- For each test case:
- T denotes the number of tree types.
- The next T integers specify the growth rates for each tree type.
- Y denotes the number of year intervals.
- The next Y integers specify the year intervals.
outputFormat
The output is written to standard output (stdout). For each test case, output a single line containing Y integers separated by a space. Each integer is the height of the tallest tree calculated as: max(growth rate) \(\times\) year for each year interval.
## sample1
3
2 3 5
4
1 2 3 4
5 10 15 20
</p>