#P4674. [BalticOI 2016 day1] Bosses

[BalticOI 2016 day1] Bosses

题目描述

A company of nn 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 nn : the number of employees. The employees are numbered 1,2,...,n1,2,...,n

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

题目大意

[BalticOI 2016 Day1]上司们

题目描述

某公司有 nn 个职员,其职员之间的阶级关系可以用一棵有根树表示,每个结点都是其所有儿子的上司。
每个职员应当分配一个工资。工资是一个正整数,且每个上司的工资必须大于它所有直系下属的工资之和。
你的任务是找到一种工资分配方案,使得以上所有条件满足且工资之和尽量小。

输入格式

第一行包含一个整数 nn,表示职员的个数,职员依次编号为 1,2,,n1,2,\dots,n
接下来 nn 行,第 ii 行包含一个整数 kik_i,以及一个包含 kik_i 个数的数列。这个数列表示第 ii 个员工的愿意接受的上司。

输出格式

输出所有方案中最小的工资之和,数据保证有解。

由 @I_love_him52 提供翻译

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

8

提示

Subtask 1 (22 points)

  • 2n102\leq n \leq 10

  • i=1nki20\sum^n_{i=1}k_i\leq 20

Subtask 2 (45 points)

  • 2n1002\leq n \leq 100

  • i=1nki200\sum^n_{i=1}k_i\leq 200

Subtask 3 (33 points)

  • 2n50002\leq n \leq 5000

  • i=1nki10000\sum^n_{i=1}k_i\leq 10000