#C13099. Weekly Work Hours Calculation
Weekly Work Hours Calculation
Weekly Work Hours Calculation
You are given the daily work hours of several employees over a week. Each employee may have fewer than 7 recorded daily hours. In such cases, the missing hours are considered to be 0. Your task is to calculate the total hours worked by each employee during the week.
Mathematically, if an employee has recorded hours \(h_1, h_2, \ldots, h_m\) with \(m < 7\), the missing days are treated as \(0\). The total working hours for that employee is computed as:
\[ T = \sum_{i=1}^{m} h_i + \sum_{i=m+1}^{7}0 \]
Read the input from stdin and output the results to stdout as specified in the input and output descriptions below. Ensure your solution can handle all test cases.
inputFormat
The input begins with an integer \(N\) representing the number of employees. Each of the next \(N\) lines contains the record for one employee. Each line starts with the employee's name followed by a sequence of integers representing the hours worked on each day. The number of integers may be less than 7. If an employee's hours are missing for some days, treat them as 0.
Example:
2 Alice 8 9 7 6 5 8 7 Bob 5 8 0 8 9 6
outputFormat
For each employee, output a single line containing the employee's name and the total number of hours worked in the week separated by a space. The order of the output should be the same as the order of the input.
Example:
Alice 50 Bob 36## sample
2
Alice 8 9 7 6 5 8 7
Charlie 6 7 8 7 6 7 9
Alice 50
Charlie 50
</p>