#P5928. [清华集训 2014] 文学
[清华集训 2014] 文学
Description
Ju Jiang and the Chairman are a pair of good friends. They both enjoy reading, and often read books in related fields together for systematic learning. One day, the Chairman made a list of books, including famous works such as Jean-Christophe and Biographies of Famous People. As a well-known young man with strong literary taste, Ju Jiang plans to finish all the books on this list in as little time as possible.
As a man of culture, Ju Jiang reads differently from ordinary people. He uses a method called “batch reading”. First, based on his preferences, he assigns two parameters to each book; for book , these parameters are . Of course, due to Ju Jiang’s unique taste, two different books may have the same parameters.
Each time he reads, he sets three coefficients . All books satisfying can be finished in this “batch reading”, and this batch reading takes a total time of .
Now, Ju Jiang has “batch reading” plans. For plan , the three parameters are , and the required time is . Ju Jiang wants to choose some of these plans so that he can finish all books in the least total time. You need to find the minimum time Ju Jiang needs.
Input Format
The first line contains two positive integers , representing the number of “batch reading” plans and the number of books.
The next lines each contain four integers. The -th line contains , describing the -th “batch reading” plan.
The next lines each contain two integers. The -th line contains , describing the parameters of the -th book.
Output Format
Output one integer in one line, representing the minimum required time. If it is impossible to finish all the books no matter what, output .
4 3
-1 0 0 10
-1 -1 -1 2
-1 1 -1 2
-1 -2 -1 1
0 2
0 -2
1 0
3
Hint
For of the testdata: , , . It is guaranteed that for any “batch reading” plan, and are not both . Also, there do not exist () such that .
Translated by ChatGPT 5
京公网安备 11011102002149号