10131_HealthyHolsteins

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

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

Pro.ID

10131

Title

Healthy Holsteins

Title链接

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

AC

44

Submit

182

Ratio

24.18%

时间&空间限制

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

    Farmer John prides himself on having the healthiest dairy cows in the world. He knows the vitamin content for one scoop of each feed type and the minimum daily vitamin requirement for the cows. Help Farmer John feed his cows so they stay healthy while minimizing the number of scoops that a cow is fed.

    Given the daily requirements of each kind of vitamin that a cow needs, identify the smallest combination of scoops of feed a cow can be fed in order to meet at least the minimum vitamin requirements.

    Vitamins are measured in integer units. Cows can be fed at most one scoop of any feed type. It is guaranteed that a solution exists for all contest input data.

    输入

    Multiple test cases. For each case:

    Line 1:   integer V ( 1 ≤ V ≤ 25 ), the number of types of vitamins

    Line 2:   V integers ( 1 ≤ each one ≤ 1000 ), the minimum requirement for each of the V vitamins that a cow requires each day

    Line 3:    integer G ( 1 ≤ G ≤ 15 ), the number of types of feeds available

    Lines 4..G+3:  V integers ( 0 ≤ each one ≤ 1000 ), the amount of each vitamin that one scoop of this feed contains. The first line of these G lines describes feed #1; the second line describes feed #2; and so on.

    输出

    Description

    Farmer John prides himself on having the healthiest dairy cows in the world. He knows the vitamin content for one scoop of each feed type and the minimum daily vitamin requirement for the cows. Help Farmer John feed his cows so they stay healthy while minimizing the number of scoops that a cow is fed.

    Given the daily requirements of each kind of vitamin that a cow needs, identify the smallest combination of scoops of feed a cow can be fed in order to meet at least the minimum vitamin requirements.

    Vitamins are measured in integer units. Cows can be fed at most one scoop of any feed type. It is guaranteed that a solution exists for all contest input data.

    Input

    Multiple test cases. For each case:

    Line 1:   integer V ( 1 ≤ V ≤ 25 ), the number of types of vitamins

    Line 2:   V integers ( 1 ≤ each one ≤ 1000 ), the minimum requirement for each of the V vitamins that a cow requires each day

    Line 3:    integer G ( 1 ≤ G ≤ 15 ), the number of types of feeds available

    Lines 4..G+3:  V integers ( 0 ≤ each one ≤ 1000 ), the amount of each vitamin that one scoop of this feed contains. The first line of these G lines describes feed #1; the second line describes feed #2; and so on.

    Output

    For each case, the output is a single line of output that contains:

    • the minimum number of scoops a cow must eat, followed by:

    • a SORTED list (from smallest to largest) of the feed types the cow is given

    If more than one set of feedtypes yield a minimum of scoops, choose the set with the smallest feedtype numbers.

    Sample Input

    4
    100 200 300 400
    3
    50   50  50  50
    200 300 200 300
    900 150 389 399

    1
    50
    1
    50

    Sample Output

    2 1 3
    1 1

    Source

    样例输入

    4
    100 200 300 400
    3
    50   50  50  50
    200 300 200 300
    900 150 389 399

    1
    50
    1
    50

    样例输出

    2 1 3
    1 1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部