The question is similar to the original one, The expected payoff of a dice game, but now we can keep $m>1$ numbers (dice).
Formally, let $X_1,...,X_n\sim \text{Unif }[0,1]$ be a sequence of i.i.d random variables coming successively. We can keep at most $m$ numbers in hand where $1<m<n$. After seeing $X_i$, you may choose to stop, or you can discard one of the $m$ numbers and see the next random variable $X_{i+1}$.
What's the best strategy to maximize the sum of these $m$ values?
(For simplicity I take $X_i\sim \text{Unif }[0,1]$. Instead you may consider a dice if you want.)