#C2178. Gift Registry Total Value
Gift Registry Total Value
Gift Registry Total Value
You are given a gift registry containing a list of gifts. Each gift is described by its type (a string which may contain spaces) and a price (an integer). The total value of the registry is the sum of the prices of all gifts.
The task is to compute the total value using the formula: \[ \text{Total Value} = \sum_{i=1}^{n} \text{price}_i \]
The input will be provided via stdin
, and the output should be printed to stdout
.
inputFormat
The first line contains an integer n, representing the number of gifts in the registry. The following n lines each contain a gift description and its price. The gift description is a string (which may include spaces) and the price is an integer. The price is always the last element on the line.
Example:
3 Teddy bear 20 Book 15 Train set 30
outputFormat
Output a single integer: the total value of all gifts.
Example:
65## sample
3
Teddy bear 20
Book 15
Train set 30
65