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

Автор hello_hell, история, 6 лет назад, По-английски

Problem Statement : Hotel Queries

for this problem, I implemented two solutions. The first solution by using merge sort tree with simple vector and Second is by using merge sort tree with multiset. Both of the solutions are giving me TLE for 3 test cases. Could you please share a better approach.

First Solution
Second Solution
  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

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

Try using ios_base::sync_with_stdio(0); cin.tie(0);

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

You can traverse the segment tree itself, and go left as long as there is value greater than $$$r$$$ on the left node. You can see my solution here. https://cses.fi/problemset/result/545774/

The size is rounded up to the next power of $$$2$$$ to make a clean segment tree allowing for an easier implementation.

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    The link doesn't show anything to me. I think after solving this question, I will be able to see other's solutions. Would you please use idone or something like that.

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