Supermarket bill

Write a program that, provided a price table, computes the bill of a
shopping basket.

Input

The input has one or more cases separated by an empty line. Each case
consists of a price table and a shopping basket. The price table begins
with a non negative integer n and after that n pairs, formed by a
product name and price, follow. The shopping basket consists of a non
negative integer m followed by m pairs formed by the number of purchased
units and the product name. We assume all product names in the shopping
basket are in the price table. All product names consist of a word of
lowercase letters. All quantities (prices and purchased units) are non
negative integers.

Output

For each case, the program has to print in a line the cost of the
shopping basket. See the examples below.

Problem information

Author: ProAl

Generation: 2026-01-25T13:45:43.757Z

© Jutge.org, 2006–2026.
https://jutge.org
