问题3046--Assignment

3046: Assignment

[命题人 : ]
时间限制 : 1.000 sec  内存限制 : 64 MB

题目描述

Last year a terrible earthquake attacked Sichuan province. About 300,000 PLA soldiers attended the rescue, also ALPCs. Our mission is to solve difficulty problems to optimization the assignment of troops. The assignment is measure by efficiency, which is an integer, and the larger the better. We have N companies of troops and M missions, M >= N. One company can get only one mission. One mission can be assigned to only one company. If company i takes mission j, we can get efficiency Eij. We have a assignment plan already, and now we want to change some companies’ missions to make the total efficiency larger. And also we want to change as less companies as possible.

输入

For each test case, the first line contains two numbers N and M. N lines follow. Each contains M integers, representing Eij. The next line contains N integers. The first one represents the mission number that company 1 takes, and so on. 1 <= N <= M <= 50, 1< Eij <= 10000. Your program should process to the end of file.

输出

For each the case print two integers X and Y. X represents the number of companies whose mission had been changed. Y represents the maximum total efficiency can be increased after changing.

样例输入 Copy

3 3
2 1 3
3 2 4
1 26 2
2 1 3
2 3
1 2 3
1 2 3
1 2

样例输出 Copy

2 26
1 2