# Exponential Distribution - Who finishes first?

Question: Anne and Betty enter a beauty parlor simultaneously, Anne to get a manicure and Betty to get a haircut. Suppose the time for a manicure (haircut) is exponentially distributed with mean 20 (30) minutes. (a) What is the probability Anne gets done first? (b) What is the expected amount of time until Anne and Betty are both done?

I have a doubt in second part of this question. I cannot wrap my head around the below explanation given in the textbook:

b) The total service rate is (1/30) + (1/20) = 5/60, so the time until the first customer completes service is exponential with mean 12 minutes. With probability 3/5, Anne is done first. When this happens the lack of memory property of the exponential implies that it will take an average of 30 minutes for Betty to complete her haircut. With probability 2/5’s Betty is done first and Anne will take an average of 20 more minutes. Combining we see that the total waiting time is 12 + (3/5)*30 + (2/5)*20 = 38

Why are we summing up the total service rate and probabilistic time (and how) to get the total expected time?

Let $F(x)$ denote the probability that both are done by time $x$. Then $$F(x)=\Pr(\text{Anne is done by time x})\cdot \Pr(\text{Betty is done by time x}).$$ Consequently, $$F(x)=(1-e^{-x/20})(1-e^{-x/30})=1-e^{-x/20}-e^{-x/30}+e^{-x/20-x/30}.$$ It can easily be verified that $$\int_{0}^{\infty}xF'(x)dx = 20+30-\frac{20\times30}{20+30}=38.$$