I start by pushing all the attacking and defending monsters of the two players in priority queues. Then, I simulate all moves the players would take greedily (not considering future game states).

The pairs \{cur, new\_cur\} I push into the vector t1 represent \{ sum1 - sum2, \ value \ of \ sum1 - sum2 \ obtained \ after \ applying \ the \ best \ move\} at every attacking step of player 1 in the sequence of moves being simulated.

t2 is similar to t1, the only difference is that it is for the player 2 and sum1 - sum2 is replaced with sum2 - sum1. t2 is not useful though.

After simulating the longest possible sequence of moves, I calculate the answer taking care of the fact that a player can end their turn at any step to maximize their score.

Hope it helps. In case it doesn’t, feel free to ask again.