#C13533. Number Statistics Analysis
Number Statistics Analysis
Number Statistics Analysis
In this problem, you are given a list of integers and you must compute summary statistics about the list. Specifically, you need to calculate:
- The sum of all positive numbers \( S_+ = \sum_{i=1}^{n} \max(0, a_i) \).
- The sum of all negative numbers \( S_- = \sum_{i=1}^{n} \min(0, a_i) \).
- The count of positive numbers.
- The count of negative numbers.
- The count of zeros.
The input is provided through standard input and the output must be printed to standard output. The output should list the computed values in the following order: sum_positive, sum_negative, count_positive, count_negative, count_zero, separated by spaces.
inputFormat
The input is read from standard input (stdin) and has the following format:
n x1 x2 x3 ... xn
Here, n
is an integer representing the number of elements in the list, followed by a line containing n
space-separated integers.
outputFormat
Output to standard output (stdout) a single line containing five space-separated integers:
sum_positive sum_negative count_positive count_negative count_zero
These integers represent the sum of all positive numbers, sum of all negative numbers, count of positive numbers, count of negative numbers, and count of zeros, respectively.
## sample8
10 -2 5 3 0 -8 0 0
18 -10 3 2 3