![]() |
2nd Central European Olympiad in InformaticsDay 2 - Problem C Measuring Glasses |
We are given three glasses. The volume of each glass is 100 unit(cm3). The first two glasses have marks, same on both glasses, each mark indicating the volume measured from the bottom up to the mark. That volume is written beside the mark. Initially the first glass contains 100 unit volume of fluid, and the others are empty. Write a program that decides whether one unit volume of fluid can be separated in the third glass, and if so, computes the minimal number of steps needed to do it. In each step, after the operation at least one of the used glass must contain fluid up to a mark or empty. During the procedure we can keep track of the actual contents of each three glasses.
Example input:
4 13 37 71 100Example output:
YES 8
v1+v2+v3=100 => v2=100-v1-v3
The program will run a little faster if we use a queue. Fortunately, it's fast enough without one.
![]() |
![]() |