#P4177. [CEOI 2008] order

[CEOI 2008] order

Description

There are NN jobs and MM types of machines. Each type of machine can either be rented or purchased. Each job consists of several operations, and each operation requires a certain type of machine to complete.

You need to maximize the profit.

Input Format

The first line gives N,MN, M.

Then, for each of the NN jobs:

  • The first line gives xix_i and tit_i, denoting the revenue of this job and the number of operations, respectively.
  • The next tit_i lines each contain two integers aija_{ij} and bijb_{ij}, denoting the machine required for this operation and the cost of renting this machine for this job, respectively.

Finally, the last MM lines each contain a positive integer yiy_i, denoting the cost of purchasing machine ii.

Output Format

The maximum profit.

2 3
100 2
1 30
2 20
100 2
1 40
3 80
50
80
110
50

Hint

Constraints: For 100%100\% of the testdata, 1N,M12001 \le N, M \le 1200, 1xi50001 \le x_i \le 5000, bij,yi20000b_{ij}, y_i \le 20000.

Translated by ChatGPT 5