Complicated math problem in national programming competition
You need to create a mixture with ratio 1:1, with maximum possible weight. You are given N different mixture's each accompanied with weight in grams and ratio. (N <= 100 and each weight will be less then or equal to 100). I tried running recursion to try every possible combination, but im only looking at integer weights, and my solution fails on the following example:
5
14 3 2
4 1 3
4 2 2
6 6 1
10 4 3
The correct output is 20.85714286, but my brute force(for obvious reasons) prints 20, not looking at decimal weights. Can anyone explain how would one approach math problems like this?