#P5951. [BalticOI 2003] Barrel (Day 1)

[BalticOI 2003] Barrel (Day 1)

Description

Given a pool with bottom area SS and height HH.

There is currently water with volume VV in it. Then nn cubes are put into the pool. For each cube, its edge length and density are given. Compute the final height of the water level in the pool.

Note: We ignore any effect of air forces. Assume that the cubes do not touch each other and do not rotate in the water, and assume the density of water is 11.

Input Format

The first line contains three integers S,H,VS, H, V.

The second line contains an integer nn.

The next nn lines each contain two real numbers: the edge length and the density of the cube.

Output Format

Output the final height of the water surface. An error of at most 10710^{-7} is accepted.

100 10 500
1
1 0.5
5.0050000

Hint

For 100%100\% of the testdata, 1S,H,V100001 \le S, H, V \le 10000, and 1n10001 \le n \le 1000.

Constraints

Translated by ChatGPT 5