#K48262. Drone Flight Distance Calculation

    ID: 28382 Type: Default 1000ms 256MiB

Drone Flight Distance Calculation

Drone Flight Distance Calculation

In this problem, you are given information about a drone's flight range without any payload and the weights of the packages it might be carrying. The drone’s maximum flight distance for each package is calculated by reducing its flight range by the weight of the package. Mathematically, the maximum distance (d) for a package of weight (w) is calculated as:

[ d = \max(0, R - w) ]

where (R) is the drone’s flight range without any payload. Although the battery capacity is provided as part of the input, it does not affect the calculation. Your task is to compute the maximum flight distance for each package delivered by the drone and output the results accordingly.

inputFormat

The input is provided via standard input (stdin) and consists of multiple test cases. Each test case begins with an integer representing the number of drone cases. For each drone case, a line with two space-separated integers is given: the flight range without payload (R) (in kilometers) and the battery capacity (in milliampere-hours). This is followed by several lines, each containing a single integer representing the weight of a package (in grams). The list of weights for a drone case is terminated by a line containing the word 'End'. A test case reading a single integer 0 indicates the end of input.

outputFormat

For each drone case, output a single line containing the maximum flight distances for each package. The distances should be separated by a single space. The result for each drone case must be printed on a new line.## sample

1
100 5000
50
100
250
End
0
50 0 0

</p>