#P2409. Y的积木
Y的积木
Description
Y has boxes of blocks, and each block has a weight. He wants to pick one block from each box and put them together; the total weight of this pile is the sum of the weights of the chosen blocks. Now he wants to know the weights of the selections with the smallest total weights. (As long as you replace any single block, it is considered a different selection. If multiple selections have the same total weight, we should output that weight multiple times.)
Input Format
The first line contains two integers, , as described.
In the next lines, line starts with an integer , the number of blocks in the -th box. On the same line, there are integers, which are the weights of the blocks.
Output Format
Output one line containing the weights of the selections with the smallest total weights, in nondecreasing order.
3 10
4 1 3 4 5
3 1 7 9
4 1 2 3 5
3 4 5 5 6 6 7 7 7 7
Hint
Constraints
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , , , each block’s weight is a positive integer not exceeding , and the product of all is at least .
This problem does not stress constant factors.
Translated by ChatGPT 5
京公网安备 11011102002149号