#P1460. [USACO2.1] 健康的荷斯坦奶牛 Healthy Holsteins
[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 , the number of vitamin types required. The second line contains integers, the minimum daily amount required for each vitamin.
The third line contains an integer , the number of available feed types. Each of the next lines contains integers; the -th of these lines gives the amounts of each vitamin contained in feed number .
Output Format
Output a single line containing the minimum number of feed types , followed by 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 of the testdata, , .
All integers in the input are in the range .
USACO 2.1
Translation from NOCOW.
Translated by ChatGPT 5
京公网安备 11011102002149号