#P1460. [USACO2.1] 健康的荷斯坦奶牛 Healthy Holsteins

    ID: 452 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>搜索USACO广度优先搜索,BFS深度优先搜索,DFS

[USACO2.1] 健康的荷斯坦奶牛 Healthy Holsteins

Description

Farmer John prides himself on having the healthiest cows in the world. He knows the minimum amount of each vitamin that the cows need from different feeds. Please help him feed his cows to keep them healthy while minimizing the number of feed types used.

Given the cows’ minimum vitamin requirements, output which types of feed to use so that the total number of feeds is minimized.

Vitamin amounts are integers. Each type of feed can be used at most once. It is guaranteed that a solution exists.

Input Format

The first line contains an integer vv, the number of vitamin types required. The second line contains vv integers, the minimum daily amount required for each vitamin.

The third line contains an integer gg, the number of available feed types. Each of the next gg lines contains vv integers; the nn-th of these lines gives the amounts of each vitamin contained in feed number nn.

Output Format

Output a single line containing the minimum number of feed types pp, followed by pp integers: the chosen feed indices in increasing order.

If there are multiple solutions, output the one with the smallest sequence of feed indices (i.e., lexicographically smallest).

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

Hint

Constraints
For 100%100\% of the testdata, 1v251\le v \le 25, 1g151\le g \le 15.
All integers in the input are in the range [1,1000][1,1000].

USACO 2.1

Translation from NOCOW.

Translated by ChatGPT 5