#C12424. Department Average Salary Calculator

    ID: 41850 Type: Default 1000ms 256MiB

Department Average Salary Calculator

Department Average Salary Calculator

This problem requires you to calculate the average salary for employees in each department. Given a list of employees with their individual salaries and departments, your task is to group the employees by department and compute the average salary for each group.

Mathematically, for each department \(d\) with salaries \(s_1, s_2, \dots, s_n\), the average salary is given by:

\( \text{Avg}_d = \frac{s_1 + s_2 + \cdots + s_n}{n} \)

The final result should be printed in alphabetical order of the department names, with each average salary displayed to exactly two decimal places.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (N), representing the number of employees. Each of the following (N) lines contains three values separated by spaces: the employee's name (a string without spaces), the department name (a string), and the salary (a number).

Example input: 5 Alice Engineering 120000 Bob HR 70000 Charlie Engineering 110000 David HR 75000 Eve Sales 90000

outputFormat

For each department, print a line in the following format:

Department: , Average Salary:

where is the average salary of that department printed with exactly two decimal places. The departments must be output in alphabetical order.## sample

5
Alice Engineering 120000
Bob HR 70000
Charlie Engineering 110000
David HR 75000
Eve Sales 90000
Department: Engineering, Average Salary: 115000.00

Department: HR, Average Salary: 72500.00 Department: Sales, Average Salary: 90000.00

</p>