#C1203. Weather Statistics
Weather Statistics
Weather Statistics
Given an array of daily temperatures, you are required to compute and output four statistics:
- Maximum Temperature
- Minimum Temperature
- Average Temperature (using floor division)
- Median Temperature
The average is computed as \(\lfloor \frac{\text{sum of temperatures}}{n} \rfloor\), where \(n\) is the number of temperature values. The median is defined as follows: if \(n\) is odd, the median is the middle element of the sorted array; if \(n\) is even, the median is \(\frac{a_{n/2} + a_{(n/2)+1}}{2}\) (the result is then cast to an integer by discarding any fractional part).
Your task is to write a program that reads the temperatures from standard input and prints the computed statistics to standard output.
inputFormat
The input is given via standard input with the following format:
- The first line contains an integer \(n\) (\(1 \leq n \leq 10^5\)), representing the number of daily temperatures.
- The second line contains \(n\) space-separated integers, each representing a daily temperature.
outputFormat
Output a single line to standard output containing four space-separated integers:
- The maximum temperature
- The minimum temperature
- The average temperature (rounded down to the nearest integer)
- The median temperature
7
30 40 20 50 10 35 25
50 10 30 30