Exercise
InterviewTime limit1sMemory limit128 MB
For each machine, multiply each exercise level's energy rate by its duration and sum the totals per person.
- Level
Easy2 of 10
- Topics
- Simulation, Implementation, Array
- Solved
- No attempts yet
Problem
A gym has several exercise machines, and each machine offers a number of levels. Harder levels burn more energy per minute than easier ones. If a person exercises at level for minutes, the energy used is , where is the energy burned per minute at level . Your task is to compute the total energy each person uses while working out on a machine.
Input
The input consists of several scenarios. Each scenario describes one machine and the people who exercise on it.
Each scenario begins with an integer (), the number of levels on the machine. The next lines give the energy burned per minute at each level: the first line is level 1, the second is level 2, and so on.
The people who used the machine follow. Each person is given on one line as their name (a single word of 2 to 10 letters, of which only the first may be uppercase) and an integer (), the number of exercises they performed, separated by a space. The next lines each give one exercise as its level and its duration in minutes, separated by a space.
The list of people for a machine ends with a line # 0, which must not be processed.
The input ends with a scenario whose is 0; this scenario must not be processed.
Output
Print one section per machine. Number the machines starting from 1. For each machine, first print a line Machine k (where is the machine number), then one line for each person who used that machine, in the order they appear in the input. Each person's line contains their name, a space, and the total energy they burned across all of their exercises.