#K36057. Total Work Hours Calculation
Total Work Hours Calculation
Total Work Hours Calculation
Given a collection of work logs, each record contains an employee's name, the number of hours worked, and the project name. Your task is to compute the total number of hours worked by each employee.
For each employee, the total hours is defined as:
\[ total\_hours = \sum_{i=1}^{k} hours_i \]
The result must be output in ascending order of the employee's name. Each line of the output should display the employee's name followed by his/her cumulative work hours (formatted to one decimal place).
inputFormat
The first line contains an integer n representing the number of work logs.
Each of the following n lines contains three tokens separated by whitespace:
- A string representing the employee's name (without spaces).
- A floating-point number indicating the number of hours worked.
- A string representing the project name (without spaces).
Note: The project name is not used in the calculation.
outputFormat
For each unique employee, output a line with the employee's name and the total number of hours worked, separated by a space. The total hours must be formatted to one decimal place. The output lines should be sorted in ascending order by the employee's name.
## sample4
Alice 5.5 Project1
Bob 3.0 Project2
Alice 2.5 Project2
Bob 4.0 Project1
Alice 8.0
Bob 7.0
</p>