#C4955. Summarize Reading Logs
Summarize Reading Logs
Summarize Reading Logs
You are given a log of reading sessions. Each session contains the book name (a string), the number of pages read (an integer), and the time taken (a float). Your task is to compute and print four values:
- The total number of unique books read, denoted as \(T\).
- The total number of pages read, denoted as \(P\).
- The total time spent reading, denoted as \(S\) (rounded to one decimal place).
- The average reading speed, computed as \(\frac{P}{S}\) (if \(S > 0\)) rounded to one decimal place, otherwise 0.
If there are no logs, all four values should be 0. Input is provided via stdin and output should be printed to stdout as a single line where values are separated by spaces.
Note: All floating-point results must be rounded to one decimal place.
inputFormat
The first line contains an integer \(n\) representing the number of reading logs. Each of the next \(n\) lines contains a reading log with three fields separated by space:
- A string representing the book name (without spaces).
- An integer representing the number of pages read.
- A float representing the time taken.
If \(n = 0\), there are no further lines.
outputFormat
Print a single line containing four values separated by a space:
- Total unique books read
- Total pages read
- Total time (rounded to one decimal place)
- Average speed (rounded to one decimal place)
4
BookA 150 2.5
BookB 200 3.0
BookA 100 1.5
BookC 300 5.0
3 750 12.0 62.5