#K76922. Calculate Total Score
Calculate Total Score
Calculate Total Score
You are given a list of strings representing contest results. Each string is formatted as x:y
, where x
is an integer (not used in the calculation) and y
is either 1
or 0.5
. If y
is 1
then it indicates a full score which contributes 1 point. If y
is 0.5
then it indicates a partial score which contributes \(0.5/2 = 0.25\) points.
Your task is to calculate the total score based on the given input. The input is read from stdin and the result must be output to stdout as a float. If no scores are provided, output 0.0.
Examples:
- Input:
3\n5:1\n3:1\n4:1
→ Output:3.0
- Input:
3\n2:0.5\n3:0.5\n1:0.5
→ Output:0.75
- Input:
4\n5:1\n3:0.5\n4:1\n2:0.5
→ Output:2.5
inputFormat
Input is read from stdin in the following format:
n score_1 score_2 ... score_n
Where n
(an integer) denotes the number of score strings that follow. Each score string is in the format x:y
, where x
is an integer (which can be ignored) and y
is either 1 or 0.5.
outputFormat
Output the total score as a float to stdout.
If there are no scores (n
is 0), output 0.0
.
3
5:1
3:1
4:1
3.0
</p>