There is a mysterious planet called Yaen, whose space is 2-dimensional. There are many beautiful stones on the planet, and the Yaen people love to collect them. They bring the stones back home and make nice mobile arts of them to decorate their 2-dimensional living rooms.
In their 2-dimensional world, a mobile is defined recursively as follows:
- a stone hung by a string, or
- a rod of length 1 with two sub-mobiles at both ends; the rod is hung by a string at the center of gravity of sub-mobiles. When the weights of the sub-mobiles are n and m, and their distances from the center of gravity are a and b respectively, the equation n * a = m * b holds.
For example, if you got three stones with weights 1, 1, and 2, here are some possible mobiles and their widths:
Given the weights of stones and the width of the room, your task is to design the widest possible mobile satisfying both of the following conditions.
- It uses all the stones.
- Its width is less than the width of the room.
You should ignore the widths of stones.
In some cases two sub-mobiles hung from both ends of a rod might overlap (see the figure on the right). Such mobiles are acceptable. The width of the example is (1/3) + 1 + (1/4).