How would you solve this in nlogn?
Is that Power Towers from Balkan OI 2016? If so, see the official solution