Study Group
Time limit2sMemory limit128 MB
Given students with skill values and sets of known algorithms, pick a group whose skill range is at most D to maximize (union size minus intersection size) times group size.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Sliding window, Sorting, Math
- Solved
- No attempts yet
Problem
Hyunwoo is a first year student who enjoys studying algorithms. This time he wants to form a study group and study even harder.
Too many cooks spoil the broth, and Hyunwoo worries that a group with too many students will drag along, so he set this condition.
The skill gap between the best student and the worst student in the group must be at most .
He also defines the efficiency of a group. Let be the number of algorithms that at least one member knows, let be the number of algorithms that every member knows, and let be the number of members. Then
To check both conditions, Hyunwoo scored every student's skill as a number and, for important algorithms, recorded which of them each student knows. Among the subsets of students that satisfy the condition, he will pick the one with the largest efficiency as his study group.
What is the efficiency of the study group Hyunwoo will form?
Input
The first line contains the number of students , the number of algorithms , and the skill gap limit . (, , )
The information of the students follows, two lines per student.
- The first line contains , the number of algorithms this student knows, and , this student's skill. (, )
- The second line contains the algorithm numbers that this student knows. () The numbers on one line are distinct. If is 0, this line is empty.
Output
Print the efficiency of the group with the largest efficiency on one line. A group of a single student always satisfies the condition, so the answer is never negative.