Approach hintTry it first, then revealHide
Each knight is eliminated at most once, so keep the knights still in play in an ordered set and erase everyone in [l, r] except the winner. The total work is O((n + m) log n).
Each knight is eliminated at most once, so keep the knights still in play in an ordered set and erase everyone in [l, r] except the winner. The total work is O((n + m) log n).