|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1.5 초||256 MB||78||32||25||37.313%|
A company of n employees is due for a restructuring. In the resulting hierarchy, represented as a rooted tree, every node will be the boss of its children.
Each employee has a list of bosses they will accept. In addition, all employees must be assigned a salary. The salary must be a positive integer, and the salary of each boss must be larger than the sum of salaries of their immediate subordinates.
Your task is to structure the company so that all above conditions hold, and the sum of all the salaries is as small as possible.
The first input line contains an integer n: the number of employees. The employees are numbered 1, 2, ..., n.
After this, the input contains n lines that describe the preferences of the employees. The ith such line contains an integer ki, followed by a list of ki integers. The list consists of all employees that the ith employee accepts as their boss.
You should output the lowest total salary among all valid restructurings. You can assume that at least one solution exists.
4 1 4 3 1 3 4 2 1 2 1 3