Блог пользователя achhadahappy

Автор achhadahappy, история, 3 года назад, По-английски

You will be given an array and some queries. Each query will contain three integers l, r, and x. You have to return the count of the integer in array in the range [l,r] whose value is less than or equal to x. for example n=7 q=2 5 4 8 7 6 2 1 1 3 5 2 5 6

ans = 2 2

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
3 года назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

You can use a merge sort tree or a wavelet tree

»
3 года назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

You can convert it into a three-dimensional partial order, and then use the Binomial theorem to solve it in n log n (not n log^2 n)