# | User | Rating |
---|---|---|

1 | Benq | 3650 |

2 | Radewoosh | 3648 |

3 | tourist | 3579 |

4 | ecnerwala | 3551 |

5 | Um_nik | 3494 |

6 | Petr | 3452 |

7 | ksun48 | 3432 |

8 | jiangly | 3349 |

9 | maroonrk | 3338 |

10 | Miracle03 | 3314 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 210 |

2 | awoo | 188 |

3 | Errichto | 186 |

3 | rng_58 | 186 |

5 | SecondThread | 182 |

6 | Um_nik | 176 |

6 | Ashishgup | 176 |

8 | maroonrk | 172 |

9 | antontrygubO_o | 171 |

10 | -is-this-fft- | 169 |

↑

↓

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/06/2021 03:25:01 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

for O((n+m) log n) solution see here

could you explain your solution?

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 number

Now if I want K-th smallest number in range [l,r] the naive way is like the code

This has complexity O(n) for each operation

I use sqrt decompstion to make it faster

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.

pre[i][j] means how many indexes between 1 and j exists in ith block

it is hard to understand idea from your code, but when you explain I got it,thanks,great idea ;)