Optimal Betting Strategy question I am preparing for an exam in probability theory and I bumped against a question I can't solve.
Given are an integer starting capital $k$, an end goal capital $m$ and a period of $n$ days. Each day I can bet some integer amount $X$ of my choosing $(X \leq k)$ on an unfair coin landing on heads. The probability the coin lands on heads is different each day, with $p_i$ denoting the probability of it landing on heads on day $i$ with $i \in (1,...,n)$. If the bet is successful, I increase my capital by $X$, if not I lose $X$ amount. (All probabilities $p_1, p_2,..., p_n$ are known before the betting process starts).
The question is: With an optimal betting strategy, what is the probability of achieving capital at least equal to $m$ after $n$ days?
An example input: $n = 5, k = 2, m = 20, p_1 = 0.3, p_2 = 0.5, p_3 = 0.2, p_4 = 0.7, p_5 = 1.0$
Though not from a homework, if this question falls under the category of questions one should solve by themselves or look for help from a tutor or elsewhere, please tell me, I will take it down. Any advice as to how to approach the problem would be awesome though.

You can also try to solve each particular case separately, some of them would be easier and some of them are harder.
For you proposed input:

*

*Obviously the game is equivalent to get at least 10 before the last turn. If you don't you can't double. If you do, you will success 100%


*There are 2 kind of strategies



*

*That do not bet anything on the first turn. In that case you have to win 4 next times, so the probability is not better then $0.5 \cdot 0.7 \cdot 0.2 \cdot 1$ and we know that there's a better strategy that gives us at least $0.5 \cdot 0.7 \cdot 0.3 \cdot 1$ (why?), so this type of strategy is not interesting.


*That bet something on the first turn. In that case they have to win on the first bet (otherwise we'll have 1 and will need to get 20 which is impossible in 4 turns(why?)). Then we may as well bet everything on the first turn (why?).
So we basically know the first and the last our turns and we have smaller problem, where $n=3, k=4, m=10, p_1=0.5,_2=0.2,p_3=0.7$ (and we need to multiply result by 0.3). Now you can use the more general idea but which will require less calculation now or continue with solving particular case
