#K3401. Currency Conversion Summation
Currency Conversion Summation
Currency Conversion Summation
You are given several price lists where each list contains pairs of a currency code and a book price. Additionally, a set of exchange rates to a target currency is provided. For each price list, for every currency-price pair \( (c, p) \), if an exchange rate \( r \) is provided for currency \( c \), then its contribution to the total cost is \( p \times r \). The task is to calculate the sum of all such converted prices.
The total cost is computed by:
\( \text{Total Cost} = \sum_{\substack{(c,p)\; \text{with available rate}}} p \times r \)
If a price's currency does not have an exchange rate provided, then that price is ignored.
inputFormat
The input is provided via stdin in the following format:
- Line 1: An integer \( n \), representing the number of price lists.
- For the next \( n \) lines: Each line begins with an integer \( m \) (an even number) denoting the number of tokens in that price list, followed by \( m \) space-separated tokens. Every two tokens represent a currency code (a string) and a price (a numeric string).
- Next line: An integer \( p \), representing the number of exchange rates.
- For the next \( p \) lines: Each line contains a currency code and its exchange rate (a floating-point number), separated by a space.
Example:
2 6 USD 10 GBP 5 EUR 12 4 JPY 5000 CNY 40 3 USD 1.2 GBP 1.5 EUR 1.1
outputFormat
Output a single floating-point number representing the total cost in the target currency. The result should be printed to stdout.
## sample2
6 USD 10 GBP 5 EUR 12
4 JPY 5000 CNY 40
3
USD 1.2
GBP 1.5
EUR 1.1
32.7