Note that the context for the problem is simplified and may not be exactly the same as what is in-game. You may directly refer to the end of the problem statement for a formal definition of the problem.
In the popular card-collecting game
Hearthstone, there is a mode called
Battlegrounds, which is based on the auto battler genre. It allows eight players to compete in each match by recruiting minions over several rounds. In Battlegrounds, there is a special minion called
Famished Felbat. It is a sixth-tier demon with stats 9/5 and has the effect of “
At the end of your turn, your other demons consume a minion in Bob's Tavern to gain its stats”.
Suppose you are playing Battlegrounds. Currently, you have

demons on the board, and there are

minions in the tavern. You also have the effect of Famished Felbat equipped. You have no coins left, so you must end the turn. You wonder what the expected strength of your warband is after you end the turn.
For the purposes of this problem, we make a few simplifications and specifications as follows:
-
We assume that each minion is associated with a single positive integer, denoting its stat. When a minion with stat
consumes another minion with stat
, its stat becomes
, and the consumed minion disappears.
-
When you have the effect of Famished Felbat equipped, at the end of your turn, the following happens: Each of your minions, ordering from left to right, sequentially chooses a remaining minion in the tavern uniformly at random and consumes it.
-
The strength
of a minion with stat
is defined as follows:
where
is some given parameter. (This formula sets strength of a minion with stat
as the expected number of hits a minion with health
can take, assuming the attack of the opponent's minion is uniformly chosen from
, in the language of real Battleground games.) The strength of your warband is the sum of the strengths over all your minions.
Formally, you have

minions with stats

from left to right, respectively. There are
)
minions in the tavern with stats

, respectively. You are also given the parameter

. At the end of your turn, the following process happens:
-
Let
be a set initially set as
, denoting the indices of remaining minions in the tavern.
-
For
, the following happens:
-
An index
is chosen from
uniformly at random, then set
and
.
3. The strength of your warband is calculated as
)
, where
)
is already defined in the statement above.
You need to calculate the
expected strength of your warband after the process above.