Suppose a food court has two areas. In Area $1$ you will receive food at a rate of $0,2$ food per seconds. In Area $2$ you will receive food at a rate of $1$ food per seconds. While being in Area $2$, you have a probability of getting kicked out of the food court with probability $p > 0$ per seconds. If kicked out you cannot return to any of the areas. Say you have $10$ minutes, and want to optimize the amount of food gained. How do you distribute your time between the two areas? Should you ever switch from one area to the other? When and how often?
The answer depends on $p$.
Suppose you decide to stay $n$ seconds in Area 2. Your best strategy is to spend those seconds after staying $600-n$ seconds in Area 1, because after you are being kicked out, you can't go back.
So you will get $0.2\times(600-n$ food from Area 1. Then, in Area 2, you'll get $0$ food with probability $p$ (you are immediately kicked out), $1$ food with probability $qp$ ($q=1-p$, you are kicked after 1 second), ... $k$ food with probability $q^kp$, $n-1$ food with probability $q^{n-1}p$, and $n$ food with probability $q^n$.
So your expected gain with this strategy is : \begin{align}E_n &=120-0.2n+qp+2q^2p+\dots+(n-1)q^{n-1}p+nq^n \\ &= 120-0.2n + pq(1+2q+\dots+(n-1)q^{n-2})+nq^n\end{align} Now $$1+2q+\dots+(n-1)q^{n-2}=(1+q+q^2+\dots+q^{n-1})'=\left(\frac{1-q^n}{1-q}\right)'=\frac{(n-1)q^n-nq^{n-1}+1}{(1-q)^2}$$ So, if my math is right : $$E_n=120-0.2n+\frac{(2n-1)q^{n+1}+1}{1+q}$$ Let's study this function of $n$ : $$E_n'=-0.2+\frac{q^{n+1}}{1+q}(2+\ln q)$$ This derivative cancels when $$q^{n+1}=\frac{0.2(1+q)}{2+\ln q}$$ i.e. $$n=\frac1q\ln\left(\frac{0.2(1+q)}{2+\ln q}\right)$$ Can't go much further, I'm afraid...