Cakes
Time limit3sMemory limit512 MB
Three eaters with different per-cake speeds share n cakes, each cake splittable into any proportions; find the minimum makespan.
- Level
Hard8 of 10
- Topics
- Binary search, Greedy, Math, Sorting
- Solved
- No attempts yet
Problem
Malfoy has got cakes as a present for his birthday party. He has decided that he wants to share these cakes with his friends Crabbe and Goyle. At the same time he doesn't want to share his birthday present with other Slytherins. So, now they want to eat all these cakes as soon as possible, so that others don't notice anything.
It is known that it takes Malfoy seconds to eat the -th cake. Also, it takes Crabbe seconds to eat the -th cake. Finally, it takes Goyle seconds to eat the -th cake. They can divide each cake into several parts: the time it takes to eat a part is proportional to the size of the part. Surely, they are going to eat cakes simultaneously. Can you find the minimum time required to eat all cakes?
Input
The first line contains a single integer : the number of cakes ().
The second line contains integers , , .
The third line contains integers , , .
The fourth line contains integers , , .
It is guaranteed that .
Output
You should print one number: the minimum time it takes Malfoy, Crabbe and Goyle to eat all cakes. Your answer will be accepted if its absolute or relative error does not exceed .