In the problem B of recent codeforces contest. I am using function upper_bound whose complexity is logn,but is still getting TLE see this 111426754 but after some minute changes in the code it got accepted see this 111426808 Now,I am not able to understand what is the difference in above codes. Please help me undestand.
Thanks in advance.








std::setandstd::multisethave bidirectional iterators that's whystd::lower_boundandstd::upper_boundwork much slowly thanset::lower_boundorset::upper_bound(same for multiset). In general, if a container has a function that is already present in namespace std, use that function because there's a reason why it's there.from https://stackoverflow.com/questions/64536493/difference-between-set-upper-bound-and-upper-boundset-begin-set-end-stl
Check the following update to your solution.
111432310