hello_hell's blog

By hello_hell, history, 5 years ago, In English

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
  • Vote: I like it
  • +8
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it
      Code