TAPS - The Water Taps
There are n taps connected to a water tank. Inlet taps are used to fill the tank and outlet taps are used to empty the tank. You are given the number of hours required for every tap to either fill the tank or empty the tank individually. The tank is initially empty. Find the time (in hours) required to fill the tank if all the taps are opened simultaneously. You can safely assume that it is always possible to fill the tank in a finite number of hours. Your solution's absolute or relative error must be strictly less than 10^-2. (i.e. your solution can make mistakes upto 0.01)
The first line consists of an integer t, the number of test cases. For each test case, the first line consists of an integer n, the number of taps followed by a line with n non-zero integers. Each value is positive if the tap is used to fill the tank and negative if the tap is used to empty the tank.
For each test case print the number of hours required to fill the tank completely when all the taps are opened simultaneously.
-5 4 3 -7 6
2 10 8 -6 4 -3 -4 2