Time limit
2s
Memory limit
128 MB
Sejun currently has G1 gold coins, S1 silver coins, and B1 bronze coins. To buy a new laptop, he needs at least G2 gold coins, at least S2 silver coins, and at least B2 bronze coins.
At the bank, each exchange must be one of the following four types.
Find the minimum number of exchanges needed so that, after all exchanges, he has at least the required number of each coin.
The first line contains the current numbers of coins, G1 S1 B1.
The second line contains the required numbers of coins, G2 S2 B2.
Every value is an integer between 0 and 1,000,000, inclusive.
Print the minimum number of exchanges needed. If it is impossible to obtain the required numbers of coins, print -1.