### LashaBukhnikashvili's blog

By LashaBukhnikashvili, 7 years ago,

here is the link of a problem,I wrote O(n log n + m log^3 n) solution,but I have wa16, here is my code.

Any help will be appreciated very much :)

• 0

 » 7 years ago, # | ← Rev. 2 →   +3 for O((n+m) log n) solution see here
•  » » 7 years ago, # ^ |   0 could you explain your solution?
•  » » » 7 years ago, # ^ | ← Rev. 2 →   0 Sort the array keeping track of indexes so I have A[0] is the index of smallest number and A[n-1] is the index of biggest numberNow if I want K-th smallest number in range [l,r] the naive way is like the code int tmp=0; for(int i=0;i
•  » » » » 7 years ago, # ^ |   +3 Can you please comment your code a bit so that it makes it easier to understand? I have no idea what your pre[][] array does and not able to understand it from the link that you've posted.
•  » » » » » 7 years ago, # ^ |   0 pre[i][j] means how many indexes between 1 and j exists in ith block
•  » » » » 7 years ago, # ^ |   0 it is hard to understand idea from your code, but when you explain I got it,thanks,great idea ;)