Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

jiraiya_777's blog

By jiraiya_777, history, 5 weeks ago, In English,

Hello Codeforces,

I was solving this problem on hackerrank.

I successfully solved it in (O(nlogm)) by submitting this (for hackkerank site). All test cases passed.

But this submission (for hackkerank site) (O(n+m)) passes all but fails this test case. Why??

Also when i try to implement the above solutions on my computer they run indefinitely on other test cases(which got accepted on hackerrank) for large values of n and m.

Help!!

Note- I have already solved the question in O(nlog(m)), so i tried for O(n+m) and this solution passed all but 1 test case.

I need help in knowing what's wrong with the 2nd approach.

 
 
 
 
  • Vote: I like it
  • -8
  • Vote: I do not like it

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

I did it using Fenwick Tree. Overkilled!

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

The test case says access denied. So can you please post the test case instead of the link.
I solved it using upper bound vector. Just removing duplicates and finding the score's position in the array will suffice.

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

Auto comment: topic has been updated by jiraiya_777 (previous revision, new revision, compare).

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

my answer you can make this more efficient. By changing the upper_bound thing and it will work i think

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

    refering to this. I would say ordered_set would be needed for this. No wonder I wasn't able to debug this solution for so long.

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

    thanks,but i have already solved the question. But my second approach (in O(n+m) ) didn't pass a test case .I want to know what's wrong in this solution, cause it seems fine to me.