Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If we ever decide to use some spell with power <code>x</code>, then we will use all spells with power <code>x</code>.
Think of dynamic programming.
<code>dp[i][j]</code> represents the maximum damage considering up to the <code>i</code>-th unique spell and <code>j</code> represents the number of spells skipped (up to 3 as per constraints).