#C6595. Calculate Total Cost of Cart Items
Calculate Total Cost of Cart Items
Calculate Total Cost of Cart Items
You are given a shopping cart containing a list of product names and a price list with product prices. Your task is to calculate the total cost of the items in the cart by summing up the prices of items that appear in the price list. If an item in the cart does not exist in the price list, it should be ignored.
The total cost \(T\) can be computed as:
\(T = \sum_{i=1}^{N} p_i \quad \text{if the product exists in the price list}\)
where \(N\) is the number of items in the cart. Use input from stdin and output the result to stdout.
inputFormat
The input is given in the following format:
- The first line contains an integer N, the number of items in the cart.
- The second line contains N space-separated strings representing the product names in the cart.
- The third line contains an integer M, the number of entries in the price list.
- The next M lines each contain a string and a float value separated by a space, representing a product name and its price.
outputFormat
Output a single float number representing the total cost of the items in the cart. The result should be printed to stdout.
## sample3
apple banana milk
3
apple 1.0
banana 0.5
milk 1.5
3.0
</p>