#K68752. Calculate Total Book Sales
Calculate Total Book Sales
Calculate Total Book Sales
You are given a list of sales records for books. Each record is represented as a triplet \( (\text{book\_id},\, \text{month\_of\_sale},\, \text{copies\_sold}) \). Your task is to calculate the total number of copies sold for each book across all months. Finally, output the results as a sorted list of pairs \( (\text{book\_id},\, \text{total\_copies\_sold}) \) in increasing order of book_id.
Note: All formulas are provided in LaTeX format.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \( n \), representing the number of records.
- Each of the following \( n \) lines contains three space-separated integers: \( book\_id \), \( month\_of\_sale \), and \( copies\_sold \).
outputFormat
Print the results to standard output (stdout) in the following format:
- For each unique \( book\_id \), print a line containing two integers: the \( book\_id \) and the corresponding total copies sold.
- The output should be sorted in increasing order of \( book\_id \).
5
101 1 5
102 3 10
101 2 7
102 3 3
103 5 1
101 12
102 13
103 1
</p>