#K15386. Weather Station Data Aggregation
Weather Station Data Aggregation
Weather Station Data Aggregation
You are given a list of temperature readings from multiple weather stations. Each reading consists of a station identifier and a temperature value. Your task is to compute, for each station, the highest and lowest temperature recorded, and then calculate the overall average temperature across all readings.
Let \(n\) be the total number of readings, and for each reading \(i\) let \(T_i\) be the temperature. The overall average temperature is defined as \[ \bar{T} = \frac{\sum_{i=1}^{n} T_i}{n} \] with the result rounded to two decimal places. If there are no readings, the average should be 0.00.
For the stations, output the results in increasing order of station identifiers. For each station, output its identifier, the maximum temperature, and the minimum temperature (in that order), each separated by a space. Finally, print the overall average temperature on a new line.
inputFormat
The input is given from stdin and has the following format:
n station_id1 temperature1 station_id2 temperature2 ... station_idn temperaturen
Where:
n
is an integer representing the number of temperature readings.- Each of the next
n
lines contains two integers: the first is the station identifier and the second is the temperature reading.
outputFormat
The output should be printed to stdout in the following format:
- For each station (in increasing station identifier order), print a line with three space-separated values: the station identifier, the highest temperature, and the lowest temperature for that station.
- After printing all station lines, print a final line containing the overall average temperature rounded to two decimal places.
10
1 23
2 17
1 29
2 20
3 -2
1 25
2 15
3 5
1 22
3 10
1 29 22
2 20 15
3 10 -2
16.40
</p>