#C11031. Total Books Ordered
Total Books Ordered
Total Books Ordered
You are given a series of orders where each order is represented by a string. The string contains a book title that may consist of multiple words, followed by an integer which represents the quantity of books ordered.
Your task is to compute the total number of books ordered over all the orders. Mathematically, if there are N orders and the quantity in the i-th order is \(Q_i\), then the total number of books \(T\) is given by:
\[ T = \sum_{i=1}^{N} Q_i \]Note that the quantity for each order is the last token in the corresponding input line.
inputFormat
The input is read from stdin and consists of:
- The first line contains an integer N representing the number of orders.
- The following N lines each contain a single order in the format
Book Title Q
, whereQ
is an integer representing the quantity ordered.
outputFormat
Output a single integer to stdout which is the total number of books ordered.
## sample3
Introduction to Algorithms 5
Clean Code 2
Design Patterns 3
10