#C9693. Calculate Employee Project Priorities
Calculate Employee Project Priorities
Calculate Employee Project Priorities
You are given n projects, each with an integer priority, and m employees. Each employee works on a subset of these projects. Your task is to compute the sum of the priorities of the projects assigned to each employee.
For each employee i, if the list of assigned projects is P_i, you need to calculate:
\( S_i = \sum_{j \in P_i} priority_j \)
Output the computed sum for each employee in the order they are provided.
inputFormat
The input is read from standard input and has the following format:
- An integer
n
representing the number of projects. - A line with
n
space-separated integers representing the priority of each project. - An integer
m
representing the number of employees. - For each of the next
m
lines, the line begins with an integerk
(the number of projects assigned to that employee), followed byk
space-separated integers indicating the 0-indexed IDs of the projects.
outputFormat
Print a single line containing m
integers separated by spaces. Each integer represents the total sum of project priorities for the corresponding employee.
4
10 20 30 40
3
2 1 2
3 0 2 3
1 3
50 80 40