You have several recipes for sausages, each of which use the same two ingredients, but possibly in different ratios. Each recipe contains a lower and upper bound for the percentage of each ingredient. This means you can use any percentages for the two ingredients as long as they add up to 100% and fall within the specified inclusive bounds.
The recipes are given as two String[]s lowerPercentage and upperPercentage. Each element in lowerPercentage and upperPercentage contains exactly two integers separated by a single space. The j-th integer in the i-th element of lowerPercentage is the lower percentage bound of ingredient j in the i-th recipe. The j-th integer in the i-th element of upperPercentage is the upper percentage bound of ingredient j in the i-th recipe.
You are given a int[] limits, the i-th element of which is the number of grams you have of ingredient i. Your goal is to make as many sausages as possible. Each sausage must weigh exactly 100 grams, and you may use each recipe at most once. Return the maximum number of sausages you can make.
|