#C7893. Calculate Accumulated Points for Popular Books
Calculate Accumulated Points for Popular Books
Calculate Accumulated Points for Popular Books
In this problem, you are given a threshold and a series of book loan records. Each record contains a book title and the number of times it has been loaned out. A book is considered popular if its loan count exceeds the threshold. For each popular book, you score points equal to the number of loans beyond the threshold; mathematically, if a book has been loaned c times and the threshold is t, its points are given by $$\max(0, c - t)$$. The objective is to calculate the total accumulated points for all popular books.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer t representing the threshold.
- The second line contains an integer n representing the number of books.
- Each of the next n lines contains a book record in the format:
title, count
. The title may contain spaces, and the count is an integer.
outputFormat
Output a single integer (to standard output) representing the total accumulated points calculated by summing \(\max(0, count - t)\) for each book record where the loan count is greater than the threshold.
## sample5
4
Moby Dick, 4
The Catcher in the Rye, 6
To Kill a Mockingbird, 7
1984, 5
3