#K81557. Egg Collection Statistics
Egg Collection Statistics
Egg Collection Statistics
You are given the number of days N and a sequence of N integers representing the number of eggs collected each day. Note that if no eggs are collected on a certain day (i.e. the count is zero), that day is excluded from the calculation of the average. You need to compute the total number of eggs collected (summing only the days with a positive count) and the average number of eggs collected on those days.
The average should be calculated as follows:
$$\text{average} = \frac{\text{Total Eggs}}{\text{Number of days with eggs}}$$
If there are no days on which eggs were collected, the average is defined to be 0.0.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer N representing the number of days.
- The second line contains N space-separated integers where each integer represents the number of eggs collected on that day.
outputFormat
Output to standard output (stdout) two values separated by a space:
- The first is the total number of eggs collected (summing only the days with a positive count).
- The second is the average number of eggs on days when eggs were collected (as a floating point number with one decimal place). If there are no positive values, output 0.0 as the average.
7
5 0 6 7 0 0 8
26 6.5
</p>