Food Competition

Time Limit: 5 Seconds
Memory Limit: 32768 KB

Milki is often bored. He was so bored once that when he was on his way home,
he noticed that there was a crowd of ants busy doing something in the tree. He
took a closer look at a branch and found that they were fighting for food.

The food, on the left side of which are team 1 and the right side team 2, is
located at the middle of the branch and weighs *W* grams. The branch is so
thin that even the most tiny little microscopic two ants can never pass each
other. However, ants are so clever that they know how to pass the food to their
teammate, so that the food can be transfered.

Only above surly could not free milki from the boredness. Soon he found out more.
Two teams of ants have different types and levels of properties. For simplicity,
we only take velocity and capacity (grams) into account. Let *Va1* stand for
the moving speed when an ant in team 1 have nothing on the back, *Va2* for
when it is carrying something (more food weight will not slow the ants down
because what really matters is the volume of the food), and *Wa* for capacity
of an ant in team 1. Correspondingly, *Vb1*,* Vb2*, and *Wb* are
for team 2. Milki wanted to know how much food would each team eventually get, so
he turned to you for help. Note that if two ants reach the food at exactly the
same time, and the food is not enough to satisfy both of them, each ant will take
half of the food, or as much as he can, and leave the rest to the other one.

**Input**

There are multiple test cases. Each case begins with three integers *N a b*
(1<=*N*<=50000 ,-100000000<=*a*<0<*b*<100000000),
which means there are *N* ants on the branch. We use a number axis pointing
to right to describe the branch. So *a* and *b* is the coordinatethe of
two end points of the branch. The next line contains *N* integers to show
the positions of the ants at the beginning. (Of course, they are all on the
breach). To make the problem easier , we assume that the food is on the origin
and an ant is never be there at the beginning. The third line also contains
*N* integers to show the direction of every ants where 1 means facing right
and -1 means facing left.Of course if one ant is moving away from the food, there
MUST be something on its back. The forth line contains seven integers:
*W Va1 Va2 Wa Vb1 Vb2 Wb *(0 < *Va1, Va2, Wa ,Vb1 ,Vb2, Wb* < 1000,
1 < *W* < 87654321)

**Output**

One line for each case, including two numbers (accurate to 1 fractional digits)
separated by a space.First one is the number of food be taken by the left group
while second one is the right side.

**Sample Input**

2 -5 8
-3 3
1 1
4 5 3 5 4 3 4

**Sample Output**

4.0 4.0

Author:

**MIN, Zhechen**
Source:

**ZOJ Monthly, January 2009**
Submit
Status