#C5794. Tallest Plant Growth
Tallest Plant Growth
Tallest Plant Growth
You are given several test cases. In each test case, there is a collection of plants. Each plant grows linearly with time, with a given initial height and a constant growth rate. For any given day d, the height of a plant is computed using the formula:
$$\text{Height} = \text{Initial} + \text{Growth} \times d$$
Your task is to determine the height of the tallest plant at the end of each specified day for every test case.
Input details for each test case are provided in a single input. Process the input from stdin
and output your results to stdout
.
inputFormat
The first line contains an integer T
, denoting the number of test cases.
For each test case, the input is structured as follows:
- An integer
N
representing the number of plants. N
integers representing the initial heights of the plants.N
integers representing the growth rates of the plants.- An integer
D
representing the number of days to query. D
integers representing the specific days to query.
The test cases are given one after another.
outputFormat
For each test case, output a single line containing D
integers separated by a space. Each integer is the height of the tallest plant at the corresponding query day.
2
3
5 10 3
1 2 2
2
1 3
2
20 30
4 2
2
5 10
12 16
40 60
</p>