#P2488. [SDOI2011] 工作安排
[SDOI2011] 工作安排
Description
Your company has received a batch of orders. The orders require your company to provide types of products, numbered , where units of type are needed. The company has employees, numbered . The types of products that employees can make differ. Each product must be made entirely by a single employee; it is not allowed to have one employee make some parts and then pass it to another employee to continue.
We use an matrix consisting of and to describe which products each employee can make. The rows and columns of the matrix are numbered and , respectively. being means employee can make product , and means employee cannot make product .
If the company assigns too much work to an employee, the employee will become unhappy. We use an anger value to describe an employee’s mood. A higher anger value means the employee is more unhappy, and a lower anger value means the employee is happier. There is a functional relationship between an employee’s anger value and the number of products assigned to them. Since employees have different endurance, these functions differ between employees.
For employee , the function between their anger value and the number of products has segments. When they make the -th products, each product increases their anger by . When they make the -th products, each product increases their anger by , and so on. For convenience, let . Then when they make the -th products, each product increases their anger by , .
Your task is to design an assignment plan for the products so that the order requirements are satisfied, and the sum of anger values of all employees is minimized. Since we do not want to use a Special Judge, and to give contestants more time for the other two problems, you only need to output the minimal sum of anger values.
Input Format
The first line contains two positive integers and , the number of employees and the number of product types.
The second line contains positive integers, where the -th integer is .
Each of the next lines contains integers describing the matrix .
Then there are sections, where the -th section describes the functional relationship between employee ’s anger value and the number of products. Each section consists of three lines: the first line is a non-negative integer ; the second line contains positive integers, where the -th integer is (if , this line does not appear, i.e., the section has only two lines); the third line contains positive integers, where the -th integer is .
Output Format
Output a single integer: the minimal possible sum of anger values.
2 3
2 2 2
1 1 0
0 0 1
1
2
1 10
1
2
1 6
24
Hint
Constraints
- There are of the testdata with .
- About of the testdata satisfy .
- About of the testdata satisfy (excluding the above testdata).
For all testdata, , , , , . All numbers are at most .
Translated by ChatGPT 5
京公网安备 11011102002149号