#graph1001. Magic Potion
Magic Potion
Magic Potion
Problem Source
ICPC Nanjing 2018 I
Problem Description
There are heroes and 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 -th hero can only kill one monster belonging to the set . Joe, the strategist, has 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 Format
The first line contains three integers indicating the number of heroes, the number of monsters and the number of bottles of potion.
Each of the next lines contains one integer , the size of , and the following integers , the indices (-based) of monsters that can be killed by the -th hero .
Output Format
Print the maximum number of monsters that can be killed by the heroes.
Sample Input 1
3 5 2
4 1 2 3 5
2 2 5
2 1 2
Sample Output 1
4
Sample Input 2
5 10 2
2 3 10
5 1 3 4 6 10
5 3 4 6 8 9
3 1 9 10
5 1 3 6 7 10
Sample Output 2
7