×

计蒜客

  1. 题库
  2. Magic Potion
  3. 问答
  • 32.57%
  • 262144K

There are $n$ heroes and $m$ monsters living in an island. The monsters became very vicious these days, so the heroes decided to diminish the monsters in the island. However, the $i$-th hero can only kill one monster belonging to the set $M_i$. Joe, the strategist, has $k$ bottles of magic potion, each of which can buff one hero's power and let him be able to kill one more monster. Since the potion is very powerful, a hero can only take at most one bottle of potion.

Please help Joe find out the maximum number of monsters that can be killed by the heroes if he uses the optimal strategy.

Input

The first line contains three integers $n, m, k$ ($1 \le n, m, k \le 500$) $\text{---}$ the number of heroes, the number of monsters and the number of bottles of potion.

Each of the next $n$ lines contains one integer $t_i$, the size of $M_i$, and the following $t_{i}$ integers $M_{i, j}$ ($1 \le j \le t_i$), the indices ($1$-based) of monsters that can be killed by the $i$-th hero ($1 \le t_i\le m, 1\leq M_{i, j} \le m$).

Output

Print the maximum number of monsters that can be killed by the heroes.

样例输入

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

样例输出

4

题目来源

ACM-ICPC Nanjing Onsite 2018

想挑战这道题吗

  • main.c