#K68682. Clean and Average Temperatures
Clean and Average Temperatures
Clean and Average Temperatures
You are given temperature readings from multiple weather stations. Each station provides n hourly readings, but some of these readings are corrupted and are represented by the value -9999
. Your task is to remove these corrupted readings from each station and calculate the average of the valid temperatures.
The average for a station is computed using the formula:
$$\text{average} = \frac{\sum_{i=1}^{k} T_i}{k}$$
where \(T_i\) are the valid temperature readings and \(k\) is the number of valid readings. The result for each station should be rounded to two decimal places.
inputFormat
The input is provided via stdin and is structured as follows:
- The first line contains two space-separated integers m and n, where m is the number of weather stations and n is the number of readings per station.
- This is followed by m lines, each containing n space-separated integers representing the temperature readings for that station.
outputFormat
Output a single line to stdout containing m floating point numbers separated by spaces. Each number is the average of the valid temperature readings for a station, rounded to two decimal places.
## sample4 5
25 30 -9999 22 24
18 -9999 35 25 20
-9999 -9999 -9999 15 -9999
30 28 27 25 -9999
25.25 24.5 15.0 27.5