Job Assignment 2
Time limit4sMemory limit256 MB
Assign each of M jobs to one of N employees who can do it with at most two jobs per employee to handle as many jobs as possible.
Problem
Kangho's company has employees and jobs to handle. Employees are numbered 1 to , and jobs are numbered 1 to .
Each employee can take at most two of the jobs that employee is able to do, and each job is taken by exactly one person.
Given the list of jobs each employee is able to do, write a program that finds how many of the jobs can be handled at most.
Input
The first line contains the number of employees and the number of jobs . ()
Each of the next lines describes one employee. The -th of these lines contains the number of jobs employee is able to do, followed by the numbers of those jobs.
Output
Print the maximum number of jobs Kangho's company can handle on the first line.