CISTFILL - Fill the Cisterns
During the next century certain regions on earth will experience severe water shortages. The old town of Uqbar has already started to prepare itself for the worst. Recently they created a network of pipes connecting the cisterns that distribute water in each neighbourhood, making it easier to fill 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.
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.
Task
Write a program that:
- reads the description of cisterns and the volume of water,
- computes the level to which the cisterns will be filled with the given amount of water,
- writes the result.
Input
The first line of the input contains the number of data sets k, 1 <= k <= 30. The data sets follow.
The first line of each data set contains one integer n, the number of cisterns, 1 <= n <= 50000. Each of the following n lines consists of 4 nonnegative integers, separated by single spaces: b, h, w, d - the base level of the cistern, its height, width and depth in meters, respectively. The integers satisfy 0 <= b <= 106 and 1 <= h*w*d <= 40000. The last line of the data set contains an integer V - the volume of water in cubic meters to be injected into the network. Integer V satisfies 1 <= V <= 2*109.
Output
The output should consist of exactly d lines, one line for each data set. Line i, 1 <= i <= d, should contain the level that the water will reach, in meters, rounded to two fractional digits, or the word "OVERFLOW" (without quotes), if the volume of water exceeds the total capacity of the cisterns.
Example
Sample input: 3 2 0 1 1 1 2 1 1 1 1 4 11 7 5 1 15 6 2 2 5 8 5 1 19 4 8 1 132 4 11 7 5 1 15 6 2 2 5 8 5 1 19 4 8 1 78 Sample output: 1.00 OVERFLOW 17.00Warning: enormous Input/Output data, be careful with certain languages
hide comments
d_billy_b:
2022-07-18 17:47:17
Where do I get more input samples? I got those three correct but when I submit it says wrong answer. I need more samples to see where my error is |
|
sarkybastard:
2022-02-10 20:38:17
@ayu_031201: Go learn Physics... what? all of it? |
|
ayu_031201:
2022-02-01 11:42:24
Go learn Physics first and don't forget to use fixed<<setprecision(2); only :) |
|
sk128:
2021-08-10 12:47:57
my solution got AC for long double and TLE for float. So take care of that.
|
|
kelvin_0179:
2021-07-07 13:12:45
if u are stuck on WA and feel the logic is correct , use epsilon (1e-8) and for printing use
|
|
singhgur_123:
2020-08-13 15:53:37
"G.O.A.T". Hint is in this string! Find out!! |
|
abhimanyu_1998:
2020-01-02 14:42:42
use long double , caused me 4 WA ;P , cakewalk concept though |
|
abhinav_jain02:
2019-05-18 09:34:49
Simple, make an array with elements equal to start depth and end depth from the bottom. Sort the array by depth. Fill the cisterns from the bottom. Keep increasing or decreasing the net area to be filled. No binary search required. |
|
blaskwolf:
2017-07-21 16:39:48
nvmfound my mistake Last edit: 2017-07-21 17:16:13 |
|
kshubham02:
2017-03-17 17:02:02
epsilon = 1e-6 gives WA. 1e-7 gives AC. Insane :/ |
Added by: | adrian |
Date: | 2004-07-02 |
Time limit: | 13s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | ACM Central European Programming Contest, Warsaw 2001 |