Why am I getting TLE even though the complexity looks O(n*log(n)) to me?
Problem: http://codeforces.com/contest/1185/problem/D
Code: http://codeforces.com/contest/1185/submission/55804919
Atcoder ABC #351 Short Solution Discussion
Codeforces Round 941 (Div 1 + 2) Solution Discussion (with Jan)