#C12882. Department Average Salary

    ID: 42358 Type: Default 1000ms 256MiB

Department Average Salary

Department Average Salary

This problem requires you to calculate the average salary of employees working in specific departments. You are given employee data consisting of an employee's name, salary, and department, along with a list of departments to be considered. The task is to compute the average salary for employees whose department is one of those specified.

If there is no employee in the specified departments, the answer should be 0. The formula used is: $$\text{average} = \frac{\text{Total Salaries}}{\text{Number of Employees}}$$

inputFormat

The input is given via stdin and has the following format:

  1. An integer n representing the number of employees.
  2. n lines follow, each containing an employee's name (a string without spaces), salary (an integer), and department (a string without spaces), separated by spaces.
  3. An integer m representing the number of departments to consider.
  4. m lines follow, each containing a department name.

outputFormat

Output the average salary of employees (as a floating-point number) whose department is among the given list of departments. If no employee qualifies, output 0. The result should be printed to stdout.

## sample
4
Alice 70000 IT
Bob 60000 HR
Charlie 80000 IT
David 45000 Finance
1
IT
75000.0