#K8146. Counting Earthquakes Relative to the Median Magnitude
Counting Earthquakes Relative to the Median Magnitude
Counting Earthquakes Relative to the Median Magnitude
You are given several datasets containing earthquake magnitudes. For each dataset, your task is to compute the number of earthquakes whose magnitude is less than or equal to the median magnitude. The median is defined as follows:
- If there is an odd number of observations, the median is the middle value.
- If there is an even number of observations, the median is given by \(\frac{a+b}{2}\), where \(a\) and \(b\) are the two middle values after sorting the dataset.
Output the count of earthquakes for each dataset on a separate line.
inputFormat
The input consists of several datasets. For each dataset:
- The first line contains an integer \(n\) representing the number of earthquake records.
- The second line contains \(n\) decimal numbers representing the earthquake magnitudes.
The input terminates with a dataset where \(n = 0\). This dataset should not be processed.
outputFormat
For each dataset, output a single integer on a separate line representing the count of earthquake magnitudes that are less than or equal to the median of that dataset.
## sample5
2.1 2.3 3.6 4.1 4.8
6
1.0 2.5 3.0 3.5 4.0 5.0
4
2.9 3.1 2.8 3.6
0
3
3
2
</p>