22693_BallsAgain

2022-5-16 18:22| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506862117200-Problem List-采集的数据-后羿采集器.html

Pro.ID

22693

Title

Balls Again

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22693

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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
    2
    3
    1 2
    2 2
    4
    5
    2 4
    2 5

    Sample Output

    1 2
    2 9

    Source

    样例输入

    2 1
    2
    3
    1 2
    2 2
    4
    5
    2 4
    2 5

    样例输出

    1 2
    2 9

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部