#C8545. Average Finishing Times
Average Finishing Times
Average Finishing Times
You are given the finishing times of participants in a race, along with their category (either male
or female
). Your task is to compute the average finishing time for each category. If there is no participant in a category, return 0 for that category.
The average finishing time is computed using the formula:
\( \text{Average} = \text{round}\left(\frac{\sum_{i=1}^{k} t_i}{k}\right) \) where \(t_i\) is the finishing time and \(k\) is the number of participants of that category.
Print the average finishing time for male participants followed by the average finishing time for female participants, separated by a space.
inputFormat
The input is provided via stdin in the following format:
n participant1 participant2 ... participantn
Here:
n
is the number of participants.- Each of the next
n
lines contains a category (eithermale
orfemale
) and a finishing time (an integer representing minutes), separated by a space.
outputFormat
The output should be printed to stdout as two integers separated by a space:
average_male average_female
If there are no participants in one of the categories, output 0 in its place.
## sample5
male 150
female 160
male 170
female 140
male 180
167 150
</p>