Please read the new rule regarding the restriction on the use of AI tools. ×

need help in stl std::upper_bound() vs it's custom implementation!

Revision en1, by bluespider, 2020-07-10 18:30:02

Hello everyone! I am new to competitive coding and asking a rookie query in a blog for the first time so apologies in advance if anything is not according to norms.

I was solving this problem today 1284B - Новый год и восходящая последовательность . Here is the editorial. Idea behind my solution is almost as in editorial. The issue is that my submission with custom function for upper_bound got tle verdict but when I used built in function for the same it got accepted.

I used the concept of binary search in my function so the overall complexity is still O(nlogn) which should get accepted(according to me).

My code for upper_bound func

86439737 is the submission which got tle. 86412015 is the submission which got accepted.

Thanks in advance!

Tags stl, c++, upper_bound()

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English bluespider 2020-07-10 18:39:51 8 Tiny change: 'xv.size() — 1;\n\n ' -> 'xv.size() - 1;\n\n '
en3 English bluespider 2020-07-10 18:33:07 10 Tiny change: 'ission:86439737] is the s' -> 'ission:86441251] is the s'
en2 English bluespider 2020-07-10 18:31:10 19
en1 English bluespider 2020-07-10 18:30:02 1251 Initial revision (published)