#Lutece0446. Water Tanks
Water Tanks
Migrated from Lutece 446 Water Tanks
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There is a system of water tanks. The water tanks are connected by pipes. Below are the illustration:
The water tanks above a certain level will be empty since the water will flow to lower ones.
Now given the height and dimensions of each water tank, as well as the total volume of water, can you calculate the level of water? To simplify the problem, water in pipes can be ignored.
The illustration describes the third case of sample input.
Input
The input contains multiple test cases.
The first line of input file is an integer , indicating the number of test cases.
For each test case:
The first line is an integer (), indicating the number of water tanks;
Then lines are followed. In each line there will be nonnegative integers: , , , , they are the base level of the cistern, its height, width and depth, measured in meters.
The last line contains a single integer (), the total volume of water.
It is guaranteed that and .
Output
For each test case, you should output a single line containing the level that the water will reach, measured in meters, and rounded up to two fractional digits
In case the volume of water exceeds the total capacity of the whole system, you should output the word OVERFLOW
instead.
Samples
Resources
5th BUPT Programming Contest Final