3020: Firefly
If you just consider every obstacle from 1 to N,
it's O(NH) and times out.
Knowing that the order among stalagmites and stalactites has no effect on the problem,
and since sorting can only make it easier, never harder,
let's sort first and then think.
Now with binary search
find the 'stalagmites greater than or equal to' the current height and
the 'stalactites greater than or equal to' the height when counting from the top as 1.
This can be done in O(logN),
and the overall time complexity becomes O(HlogN).
3079: Immigration
Add up the number of people each booth can process within a given time, and
run binary search with the number of people to be processed as the boundary