#K63832. Taco Transaction Cost Calculator

    ID: 31841 Type: Default 1000ms 256MiB

Taco Transaction Cost Calculator

Taco Transaction Cost Calculator

You are given a series of transactions. Each transaction begins with an integer m indicating the number of items purchased, followed by m lines. Each line contains a product code and a quantity separated by a space. Your task is to calculate the total cost for each transaction using the following price list:

  • A1: $150
  • B2: $200
  • C3: $300
  • D4: $100

The total cost for a transaction is computed as:

\( \text{total} = \sum_{i=1}^{m} (\text{price of item}_i \times \text{quantity}_i) \)

The input terminates when a transaction with m = 0 is encountered. In this case, no further processing is done.

Note: It is guaranteed that the product code will be one of the four valid codes listed above. If an invalid code is provided, the behavior is undefined.

inputFormat

The input is given via stdin and consists of several transactions. Each transaction is structured as follows:

  1. An integer m on a single line, representing the number of items in the transaction.
  2. m subsequent lines, each containing a product code and a quantity separated by a space.

The input terminates with a line containing a single 0, which should not be processed.

outputFormat

For each transaction, output the total cost on a new line to stdout.

For example, if there are two transactions with totals 800 and 500 respectively, the output should be:

800
500
## sample
3
A1 2
B2 1
D4 3
2
C3 1
D4 2
0
800

500

</p>