Time consumption for finding upper bound and lower bound in multiset in C++.

Revision en1, by Hacker_Dt, 2025-01-01 18:45:03

I was solving CSES problem-set problem called Concert Ticket under the heading Searching and Sorting. Link to the problem : https://cses.fi/problemset/task/1091/ In this the array of price of ticket was to be stored in a multiset and for each price we needed to find the upper bound of the element in the multiset of ticket. I first used upper_bound(ticket.begin(),ticket.end(),price[i]) but it gave tle on some testcases.

Then I changed it to**ticket.upper_bound(price[i])** it was able to pass all the test case.

If somebody knows the reason kindly tell.

Hope it helps..

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Hacker_Dt 2025-01-01 18:45:03 672 Initial revision (published)