Here is an outline of an algorithm using dynamic programming to solveYou are on the right track.
It turns out the original question can be solved by a greedy algorithm. (A full blown solution by dynamic programming as I tried a while ago is both an overkill on coding and short of performance.)
You can create a 3-dimensional array $b$, whereLet us use the notation in the original question. $b[i,j,k]$$R$ is true iffor the first $i$ friends can makeresistance capacity. $j$ kicks$S$ is for the array of totalstrengths.
Let the index of the first minimum strength be $k$$m$. All elements inThen the maximum number of kicks is $b$ are initialized to be false$n = R/S[m]$. FirstlySo $O=[m, m, \cdots, m]$, you can compute the case whenwhere the first friend makes somenumber of $m$'s is $n$, is a kick order with maximum number of kicks, with total strength $n*S[m]$. Then you
How can compute the case whenwe get a lexicographically smaller order with the first two friend make somesame number of kicks. Then? If we can find an index $i$ smaller than $m$ such that we can replace a kick of strength $S[m]$ by a kick of strength $S[i]$ without overpassing the case withresistance capacity $R$, then we can replace the first three friends and so on. The recurrence relation will be roughly likeelement in $b[i,j,k]$ is true if$O$ by $b[i-1,j-t,k-t*s_{i}]$ is true for some nonnegative integer$i$, making the order lexicographically smaller. To make it as lexicographically as small as possible, we would like the index $t$$i$ as small as possible and, wherethen, we would like to use it as many times as possible.
For example, $s_i$ is$R = 11, S = [6, 8, 5, 4, 7, 4]$. Then the kickfirst minimum strength ofis the first 4 whose index is 3. So $i$-th student$n=11/4=2$ and $O=[3,3]$ with total strength $4*2=8$. Once you have computedTo make it smaller, we will check the arraystrengths before 4 in order. The first one is $b$$6$. Since (by$8-4+6=10<11$, we find a nested loop of three levels)smaller order $[0,3]$. If we apply 6 again, itwe would get $10-4+6=12 > 11$. So we go ahead to check the next strength 8, which is easytoo large. So we go ahead to check 5. Since $10-4+5=11\le 11$, we find "the lexicographically smallesta smaller order of friends to kick Tushar so that$[0,2]$. Since the cumulative kick strengthroom left for replacement, (sum of$11-11 =0$, we stop our effort. The final answer is [0,2].
I have verified that my program wrote along the strengths of friends who kicks) doesn’t exceed his resistance capacity and total no"above approach works. Hopefully, I have written enough to encourage you to go ahead. Hopefully, I have not written too much to spoil the fun for you.
This problem is a variation of the unbounded knapsack problem.