logo AlgoBeat OnlineJudge
登录 注册

#203662. [BalticOI 2016] Bosses (day1)

内存限制:250 MiB 时间限制:1500 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A company of 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 mustbe assigned a salary. The salary must be a positive integer, and the salary of eachboss 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 sumof all the salaries is as small as possible.

输入格式

The first input line contains an integer : the number of employees. The employees are numbered

.After this, the input contains lines that describe the preferences of the employees.The th such line contains an integer , followed by a list of integers. The list consists of all employees that the th 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.

样例

样例输入 1

4
1 4
3 1 3 4
2 1 2
1 3

样例输出 1

8

数据范围与提示

Subtask 1 (22 points)

Subtask 2 (45 points)

Subtask 3 (33 points)