#P3410. 拍照
拍照
Description
Xiao B has subordinates. Now Xiao B plans to bring some subordinates to have photos taken.
There are people; each person is willing to pay Xiao B some money to take a photo with some of the subordinates. If that set of subordinates is not fully brought, the photo cannot be taken, and Xiao B will not receive the payment.
Note: Bringing subordinates is not free! For each subordinate who is brought, Xiao B needs to pay a fee to ensure cooperation during the photo.
Input Format
The first line contains positive integers and . The next lines each describe one requester’s data. The first number is the fee he agrees to pay for that photo; then follow the IDs of the required subordinates, terminated by a as the end marker for the line. The last line contains numbers, the cost to bring each subordinate.
Output Format
A single number, the maximum profit. Xiao B may choose to bring nobody.
2 3
10 1 2 0
25 2 3 0
5 6 7
17
Hint
For of the testdata, each person requires all subordinates.
For of the testdata, .
For another of the testdata, the answer is .
For of the testdata, .
For another of the testdata, each person requires exactly one subordinate.
For of the testdata, , and fees are integers in .
Translated by ChatGPT 5
京公网安备 11011102002149号