Job Assignment at Kangho's Company
Time limit2sMemory limit256 MB
Assign each employee at most one job they can do so the number of finished jobs is largest, then maximize the total salary over those assignments.
- Level
Medium7 of 10
- Topics
- Graph, Shortest path
- Solved
- No attempts yet
Problem
Kangho's company has employees and jobs to finish. Employees are numbered 1 through , and jobs are numbered 1 through .
Each employee can take at most one job, and only from the list of jobs that employee can do. Each job is taken by at most one employee. Some employees may end up with no job.
For every employee you are given the list of jobs that employee can do and the salary Kangho must pay for each of them. Write a program that finds how many of the jobs can be finished at most, and the largest total salary Kangho pays among the assignments that finish that many jobs.
Input
The first line contains the number of employees and the number of jobs . ()
Each of the next lines describes one employee. Line starts with (), the number of jobs employee can do, followed by pairs of numbers. Each pair is a job number and the salary that must be paid when employee takes that job. A salary is 0 or a natural number no greater than 10,000.
Output
On the first line, print the largest number of jobs that Kangho's company can finish.
On the second line, print the largest total salary Kangho must pay among the assignments that finish that many jobs.