Maximize the total salary after department-wide increment or decrement tasks on a company hierarchy.
Unlock detailed company stats for this questionUpgrade
Every employee reports to exactly one manager except the CEO, forming a proper hierarchy. Everyone's salary starts at 0. You perform a set of tasks; each task increments or decrements salary, but not for a specific employee: it applies to that employee's whole department. Choose how to apply the tasks so salaries are maximized, and return the sum of everyone's salary after the transformation. Every employee can also be a manager.
Input: first line has the number of employees and number of tasks (3 1). Then n-1 lines 'a b' meaning a is the manager of b (1 2, 1 3). Then each task: number of candidate employees, the increment value, and the employee list (2 10 2 3).
Format · Technical round.
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
