Baltic Olympiad in Informatics: 2003 Day 1, Problem 1
Some amount of water is poured into a barrel, then a number of cubes of different size and density are put into water. Finally, a lid is put onto the barrel and pushed down until it touches the edges of the barrel.
Write a program to compute the resulting water level in the barrel.
It can be assumed that:
- the density of water is ,
- the influence of air can be neglected,
- the cubes fit completely into the barrel,
- the cubes do not rotate and do not touch each other.
Input Specification
The first line contains three real numbers - the bottom area of the barrel , the height of the barrel , and the volume of the water . The next line contains the number of cubes . It is followed by lines, each containing two real numbers describing the cube - the length of a side of the cube , and the density of the cube .
Output Specification
The first and only line of the output must contain one real number - the resulting water level. The output must not differ from the correct value by more than .
Sample Input
100 10 500
1
1 0.5
Sample Output
5.0050
Comments