Find maximum gold each miner can mine if both mine optimally.

44 Views Asked by At

Problem:

Chef and Chefu work as gold miners.

There are $N$ gold mines numbered from $1$ to $N$, $i$-th mine having $G_i$ gold.

If Chef alone works in mine numbered $i$, it’d take him $A_i$ days to completely mine it.
Similarly, if Chefu alone works in mine numbered $i$, it’d take him $B_i$ days to completely mine it.

Find the maximum amount of gold each miner can mine if both mine optimally.

Source:

Problem is taken from Codechef (https://discuss.codechef.com/t/golmine-editorial/69982)

Many people are facing problem with the solution. It'd be great if someone can explain in detail that why is it optimal for both miners to work in the same mine all the time.