Assigning Jobs 5
Time limit2sMemory limit256 MB
Assign each employee at most one job they can do so the number of finished jobs is largest and the total salary is smallest.
- Level
Medium7 of 10
- Topics
- Graph, Shortest path
- Solved
- No attempts yet
Problem
Gangho's company has employees and jobs to finish. Employees are numbered 1 to , and jobs are numbered 1 to .
Each employee handles at most one of the jobs that employee can do, and no job is handled by more than one employee. When an employee handles a job, Gangho pays that employee the salary fixed for that job.
You are given the list of jobs each employee can do together with the salary for each of them. Write a program that finds the largest number of jobs the company can finish, and the smallest total salary Gangho 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, each of which is a job number and the salary for that job. is between 0 and , and no employee lists the same job twice. Every salary is an integer between 0 and 10,000.
Output
On the first line, print the largest number of jobs the company can finish.
On the second line, print the smallest total salary among the assignments that finish that many jobs.