Groundwater Reserves
Time limit1sMemory limit256 MB
Uniform rain fills a walled polygonal reservoir where each basin spills over its lower rim once full, and the task asks for the highest water surface reached.
- Level
Medium7 of 10
- Topics
- Simulation, Geometry, Sorting
- Solved
- No attempts yet
Problem
Groundwater is the word for the lakes, ponds, and rivers that form underground. When it rains, part of the water percolates through the layers of soil and rock and ends up in one of those bodies of water somewhere below the surface. Plants with long enough roots draw on groundwater when no rain has fallen for a while, and people reach it by drilling wells deep enough. A drought leaves the reserves partly or completely empty, and refilling them takes a lot of rain.
In this problem the reserves start completely empty, and you compute how far rainfall refills them. The rock at the bottom of the reservoir is given as a polyline through the points . The coordinates increase strictly from to , and no segment is exactly horizontal, so the direction in which the water landing at a point flows is always determined. A point with a larger sits higher up, and the sky is at . Infinitely high walls stand at and , so no water leaves the map.
Rain falls vertically and evenly over the whole width. A rate of means that units of water hit each unit of horizontal length per unit of time, so during a duration the horizontal interval receives units of water. Water that lands on a slope runs downhill into a basin. Once a basin is full, the surplus flows over the lower of the two ridges that bound it and into the next basin. The reservoir starts completely empty.
Find the highest level the water surface reaches anywhere in the reservoir during the units of time it rains.
Input
The first line is the number of data sets. The data sets follow, each in this form.
The first line of a data set holds three numbers , , . The integer is the number of points in the reservoir bottom contour, . The double is the rate at which rain falls, . The double is the duration for which rain falls, .
The next line holds doubles describing the points of the bottom contour in the order . It is guaranteed that and . Two neighboring points never share the same value.
Output
For each data set, print Data Set x: on a line by itself, where is its number counting from 1.
On the next line, print the highest level the water surface reached anywhere in the reservoir, rounded to exactly two digits after the decimal point. A basin that holds no water counts as having its surface at the height of its floor.
Print a blank line after each data set.