Professor invites his friends on his birthday. He wants to reward all of them and make them happy. The friend will be happy if the friend gets at least units of cryptocurrency coins.
Professor is hiring miners and they are capable of mining cryptocurrency coins per unit time. Professor is also a special cryptocurrency miner and he can mine cryptocurrency coins per unit time. So there is a total of miners including the Professor.
At each unit time, Professor distributes the cryptocurrencies among his friends. The distribution procedure is as follows:
A friend can have coins only from a single miner or no coins at all. That means, when the Professor gives coins to a friend at a particular time, the friend cannot have coins from the other source at that time unit.
Coins mined by a miner can not be split up i.e. if the Professor chooses to give miner ’s coins to a friend , then gets all the coins mined by at this unit time.
Unused coins will be lost and can not be used in the next round.
Now you have to answer the minimum units of time needed for the Professor to fulfill all his friends’ requirements.
The first line contains one integer denoting the number of Professor’s friends.
Second line contains n elements number of cryptocurrency coins needed for friends.
The next line contains two integer x, y , the number of cryptocurrency coins mined per unit time by the miners and number of cryptocurrency coins mined per unit time by the Professor respectively.
Print a single line indicating the minimum number of time needed so that the Professor can fulfill all of his friends’ requirements.
Input | Output |
---|---|
3 3 5 6 1 3 | 3 |
Initial requirement [3,5,6] Time -1: [2,4,3], Professor gave his cryptocurrency coin to friend-3, other friends took from general miners. Time-2: [1,3,0], Professor gave his cryptocurrency coin to friend-3, other friends took from general miners. Time-3: [0,0,0], Professor gave his cryptocurrency coin to friend-2, other friends took from general miners. |
Input | Output |
---|---|
3 6 10 5 9 9 | 2 |