All submissions for this problem are available.
Niranjan Viladkar is distressed of the water shortages that many villages are facing so he decides to formulate a mechanism which would store water so that it would be available for the people in a judicious way, So he created a network of pipes connecting the cisterns that distribute water in each neighborhood, making it easier to them at once from a single source of water. But, in case of water shortage, the cisterns above a certain level will be empty since the water will flow to the cisterns below.
So now it's your turn to help him.
You have been asked to write a program to compute the level to which cisterns will be filled with
a certain volume of water, given the dimensions and position of each cistern. To simplify we will
neglect the volume of water in the pipes.
As input you receive the number of cisterns, followed by one line per cistern with 4 floating point
Values: its base level, depth, width and height in meters. The last input line gives you the volume
in cubic meters to be injected into the network. And a # denotes the end of the file.
Your program must output the level that the water will reach, in meters, truncated to two fractional
digits. If the volume of water exceeds the total capacity of the cisterns then your program must
Sample input 4 11.0 1.0 5.0 7.0 15.0 1.0 4.0 6.0 5.0 1.0 5.0 8.0 19.0 1.0 8.0 4.0 78.0 # Sample Output 17.00
|Time Limit:||3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.