I was reading to levlam's code for Codeforces 85D (Sum of Medians) : http://pastie.org/3224822
It is nice how he does insertion and elimination of elements in O(lg n) by using lower_bound, but I can't understand why the code passes since it has complexity O(n / 5) for each sum query. Could someone explain why it passes?
By n I mean the number of elements currently stored at the vector.