Czech Technical University in Prague
ACM ICPC sponsored by IBM
Central Europe Regional Contest 2007
Tou gh Wat er Level
water.c | water.C | water.java | water.p
Czech Technical University has the word "technical" in its name. Beside others, this means
that lectures in physics are important here. Do you still remember some of the basic physical
principles.
For example, imagine a simple glass of water. Or, we will rather call it a cup to avoid ambiguity
of this word. So, imagine a simple cup (made of glass) that is partially filled with water. You
might have noticed that the stability of such a cup depends on the amount of water inside. If
you brush against a full cup, it is relatively easy to knock it down and spill its contents. If the
cup is empty, there is fortunately nothing to be spilled, but other than that, the situation does
not improve much - it is still easy to knock the cup down with only a little force. The best
stability is usually achieved with a "half-full" cup.
In this problem, your task is to determine the water level that makes a cup as much stable as
possible. For the purpose of this problem, we will make a simple assumption that the "stability"
of a cup is higher, if its center of mass (sometimes also called the center of gravity) is lower
(closer to the bottom).
The center of mass can be informally defined as follows: Imagine that glass and water consist of
a very large number of very small particles. Then the center of mass is an average of the position
of all these particles. The average is weighted by particle masses. Since the density of glass is
approximately 2 500 kg.m
-3
and the density of water only 1 000 kg.m
-3
, we will suppose that
the mass of a glass particle is 2.5 times higher than the mass of a water particle of the same
size.
All cups considered in this problem will have an exact rotary shape. But their radius may vary
with the height - some cups are wider at the top, others are wider at the bottom. Also, the
thickness of the glass may not be constant.
H
R
T
B
x
The left figure shows a typical cup considered in this problem. It can be fully described by its
height (H), thickness of the bottom (B), and two functions R and T . Both of these functions
take a current height as their argument and they give the outer radius (R) and glass thickness (T )
in the appropriate height. Please note that the thickness is always measured strictly horizontally
and may therefore not reflect the "real thickness" of the glass in its usual meaning.