#C13412. Vending Machine Simulation

    ID: 42948 Type: Default 1000ms 256MiB

Vending Machine Simulation

Vending Machine Simulation

This problem simulates the operation of a simple vending machine. The machine maintains an inventory of products with their available quantities and a price list with each product's cost. When a purchase request is made, the machine checks if the product exists, if it is in stock, and whether the inserted money is sufficient. If all conditions are met, it dispenses the product, updates the inventory, and returns the change computed by the formula \(change = money\ inserted - price\). Otherwise, an appropriate error message is generated.

inputFormat

Input Format:

  1. An integer N representing the number of inventory items.
  2. Next N lines, each containing a product name (a string without spaces) and an integer representing its available quantity.
  3. An integer M representing the number of entries in the price list.
  4. Next M lines, each containing a product name and a floating-point number representing its price.
  5. An integer K representing the number of purchase requests.
  6. Next K lines, each containing a product name and a floating-point number representing the inserted money for that purchase.

outputFormat

Output Format:

For each purchase request, output a line with the corresponding message. After processing all requests, output one line containing the final inventory as a JSON object (keys and their updated quantities).

## sample
2
soda 5
chips 3
2
soda 1.5
chips 1.0
1
soda 2.0
Purchased 'soda'. Change to be returned: 0.5

{"soda": 4, "chips": 3}

</p>