Pro.ID22693 TitleBalls Again Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22693 AC0 Submit0 Ratio- 时间&空间限制描述Yes, balls again! Given n different color balls with points marked on them and m different columniform bottles. Each bottle has limited capacity to hold in balls. Now the job is to put the balls into the bottles. As his name, Max wants to know the maximum number of balls that can be put into bottles and meanwhile maximize the sum of points of the balls inside bottles. 输入Input contains multiple test data sets. For each data set, first comes two integers n, m ( 1 ≤ n, m ≤ 200 ) in one line. Then n lines follow with one integer p ( 1 ≤ p ≤ 106 ), the point of corresponding ball, per each line. Then follows m lines. Each has two integers c and q ( 0 ≤ c ≤ 200, 1 ≤ q ≤ 106 ), the capacity of corresponding bottle (that is the maximum number of balls that bottle can hold) and the upper limit of point in the bottle (this means that all balls in this bottle should not have point larger than q). Input is terminated by EOF. 输出Description Yes, balls again! Given n different color balls with points marked on them and m different columniform bottles. Each bottle has limited capacity to hold in balls. Now the job is to put the balls into the bottles. As his name, Max wants to know the maximum number of balls that can be put into bottles and meanwhile maximize the sum of points of the balls inside bottles. Input Input contains multiple test data sets. For each data set, first comes two integers n, m ( 1 ≤ n, m ≤ 200 ) in one line. Then n lines follow with one integer p ( 1 ≤ p ≤ 106 ), the point of corresponding ball, per each line. Then follows m lines. Each has two integers c and q ( 0 ≤ c ≤ 200, 1 ≤ q ≤ 106 ), the capacity of corresponding bottle (that is the maximum number of balls that bottle can hold) and the upper limit of point in the bottle (this means that all balls in this bottle should not have point larger than q). Input is terminated by EOF. Output For each test data set, one output data set should be generated as follow: Generates two integers in one line: B, the maximum number of balls filled into bottles. And S, the maximum sum of points of that B balls which are inside bottles. Sample Input 2 1 Sample Output 1 2 Source 样例输入2 1 样例输出1 2 作者 |