Editorial for Removal Sorting
Submitting an official solution before solving the problem yourself is a bannable offence.
Now we get to the harder problems. The goal is to find when the earliest point in time when the array \(A\) will be sorted when deleting elements in it given from \(D\).
Something to keep in mind here is that your algorithm will be at least \(O(n)\) as it takes \(n\) reads to tell if \(A\) is sorted.
There's a trivial \(O(n^2)\) solution, where you simply iterate through \(D\), deleting elements from \(A\) as you go and checking to see if its sorted after every deletion. There were a few incorrectly coded attempts at this method, which is just as well, because it will not run in time.
If we do a binary search on \(D\) to find where the cross over point is instead of doing a linear seach, our algorithm goes from \(O(n^2)\) to \(O(n \log n)\), good enough to fit in the time restriction.