#C6595. Calculate Total Cost of Cart Items

    ID: 50372 Type: Default 1000ms 256MiB

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:

  1. The first line contains an integer N, the number of items in the cart.
  2. The second line contains N space-separated strings representing the product names in the cart.
  3. The third line contains an integer M, the number of entries in the price list.
  4. 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.

## sample
3
apple banana milk
3
apple 1.0
banana 0.5
milk 1.5
3.0

</p>