#C2064. Calculate Order Calories
Calculate Order Calories
Calculate Order Calories
In this problem, you are given a menu of dishes and their corresponding calorie values, as well as a list of customer orders. Each order contains an order ID, a customer name, and a list of items ordered. Your task is to compute the total number of calories for each order.
For each order, the total calories is computed using the formula:
where caloriesi is the calorie value of the ith dish in the order and n is the number of items in the order.
Read the input from stdin and print the result to stdout in the specified format.
inputFormat
The input is provided via standard input (stdin) in the following format:
M DishName1 Calories1 DishName2 Calories2 ... DishNameM CaloriesM N OrderID1 CustomerName1: Item1, Item2, ... OrderID2 CustomerName2: Item1, Item2, ... ... OrderIDN CustomerNameN: Item1, Item2, ...
Here, M
is the number of dishes available on the menu. Each of the next M
lines contains the name of a dish and its calorie value separated by a space. Then, N
is the number of orders. Each of the following N
lines contains an order in the format shown.
outputFormat
For each order, output one line containing the order ID, the customer name, and the total calories of all items in that order. The output should be printed to standard output (stdout).
OrderID CustomerName TotalCalories## sample
3
Pizza 300
Burger 500
Salad 150
2
101 John Doe: Pizza, Salad
102 Jane Smith: Burger, Salad
101 John Doe 450
102 Jane Smith 650
</p>