ICPC East Central NA Regional Contest 2016, Problem I
"Waif Until Dark" is a daycare center specializing in children of households where both parents work during the day. In order to keep the little monsters … that is, darlings … occupied, the center has a set of toys that the kiddies can play with. Some of these toys belong to one of several categories – sports toys, musical toys, dolls, etc. In order to save wear and tear on these types of toys, the teachers allow only certain numbers of toys of each category to be used during playtime. Of course, kids being kids, not all of the toys are liked by everyone, so sometimes it's difficult to make sure every kid has a toy they like. Given all of these constraints, the CEO of Waif has come to you to write a little program to determine the maximum number of these monsters (let's be honest here) who can be satisfied.
Input Specification
Input starts with a line containing three integers indicating the number of children, the number of toys and the number of toy categories
. Both children and toys are numbered starting at
. After this line are
lines of the form
; the
of these lines indicates that child
is willing to play with toys
through
. Next are
lines of the form
; the
of these lines indicates that toys
through
are in category
and that at most
of these toys can be used. Toys can be in at most one category and any toy not listed in these
lines is not in any toy category and all of them can be used. No toy number appears more than once on any line.
Output Specification
Display the maximum number of children that can be satisfied with a toy that they like.
Sample Input
4 3 1
2 1 2
2 1 2
1 3
1 3
2 1 2 1
Sample Output
2
Comments