i was trying to solve this problem:- https://mirror.codeforces.com/contest/1801/problem/B
My solution :- https://mirror.codeforces.com/contest/1801/submission/278323418
In my solution i wrote a O(nlogn) solution and the judge is showing time limit exceeded. But in editorial the solution given is O(nlogn) and that is getting passed. I am having trouble understanding how this is happening.
plzz help :,(
Auto comment: topic has been updated by proAakash (previous revision, new revision, compare).
set
has its own object functionlower_bound
to use. Do not uselower_bound
inalgorithm.h
, as performing it onset
would most of the time cause an $$$\mathcal{O}(n)$$$ time complexity per call.Resubmitted but WA: 278326222. Well, since I didn't solve this one yet, I wouldn't give further advice, but at least the TLE is dealt with.
got accepted thanks!! You are a life saver : )
why lower_bound that isn't method in set object act in o(n)
Please refer to this: