Math, asked by Bantishaikh2344, 9 months ago

Difference between the number of balls in a box that contains the maximum number of balls and a box that contains the minimum number of balls among the chosen boxes is the smallest possible.

Answers

Answered by ronit496
0

Answer:

Misha loves to collect sets of colored balls. She saw N boxes kept in a store. Each box has a set of 10 distinct colored balls. The colors are numbered from 1 to 10. Each box has a cost associated with it. She is required to spend the minimum amount of money to buy the boxes such that she has maximum distinct colored balls in the end.

Input format

First line: N denoting the number of boxes kept in a store

Next N lines: An integer denoting the cost of the box Ci and a binary string Si of length 10. If the jth character of the string Si is 1 then it means that there exists a ball of color j in that box.

Output format

Print the minimum amount of money that she has to spend.

Similar questions