PROBLEM STATEMENT
In Chemistry, there's a different meaning to the word 'solution' than in programming. When we mix
x liters of some substance with (100-x) liters of water, we get 100 liters of x-% solution of that
substance.
You are given several bottles containing solutions of the same substance. The i-th bottle contains
amount[i] liters of percent[i]-% solution. Return the maximal number of liters of need-% solution
we can get by pouring together some of these bottles (possibly partially, see example 0).
DEFINITION
Class:MixingLiquids
Method:howMuch
Parameters:vector , vector , int
Returns:double
Method signature:double howMuch(vector percent, vector amount, int need)
NOTES
-The returned value must have an absolute or relative error less than 1e-9.
CONSTRAINTS
-percent will contain between 1 and 50 elements, inclusive.
-Each element of percent will be between 0 and 100, inclusive.
-amount will contain the same number of elements as percent.
-Each element of amount will be between 1 and 1000, inclusive.
-need will be between 0 and 100, inclusive.
EXAMPLES
0)
{0, 100}
{20, 30}
50
Returns: 40.0
We have 20 liters of water and 30 liters of pure substance. We need a 50% solution, so we combine
all the water with 20 liters of substance.
1)
{0, 100}
{20, 30}
60
Returns: 50.0
We can use everything we have.
2)
{90, 70, 80}
{10, 10, 10}
50
Returns: 0.0
All our bottles contain too much substance.
3)
{30, 80, 60}
{40, 10, 15}
57
Returns: 35.18518518518519
4)
{50,50,50}
{395,971,964}
50
Returns: 2330.0
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.