### anajin's blog

By anajin, 4 years ago, ,

I search it in google , but i can't find it. Can somebody tell me how to use lower_bound in set<pair<int,int>> , so i can find the fist pair whose first element is not small than the element i search for ?

•
• +3
•

 » 4 years ago, # |   +35 x.lower_bound({first, -inf});
•  » » 4 years ago, # ^ |   0 got it! Thanks.
•  » » 3 years ago, # ^ |   0 Could you explain the reasoning behind using that ? Also could you tell how you would do it for upper_bound ? Thanks :)
•  » » » 3 years ago, # ^ |   0 x.upper_bound({first, inf});
•  » » » 10 months ago, # ^ |   0 In these implementations we only care about the first value.pair will compare the first int first, then the second int. We want ALL second integers to workAs for upperbound Na2a uses {first, inf} because we want the value to be greater than first, and {first, inf} is the highest pair with first as its first value. (again, we only care about the first value)
•  » » 4 months ago, # ^ |   0 How to get the index of that pair,i mean we can't do this:x.lower_bound({first,-inf})-x.begin()?
•  » » » 4 months ago, # ^ | ← Rev. 2 →   +9 There is no way to do that, set can't get index of key. You can use this though http://codeforces.com/blog/entry/11080
 » 4 years ago, # |   -18 This is a pretty good site : http://bit.ly/1DMMnub
•  » » 4 years ago, # ^ |   0 I didn't knew such site exists!
•  » » 10 months ago, # ^ |   -13 Wow , Awesome site .
•  » » » 10 months ago, # ^ |   +15 Wow , Awesome necro .
•  » » 10 months ago, # ^ |   +53 Your link actually gives us the link of this blog -
•  » » » 10 months ago, # ^ |   +42 Well, there is actually an answer on that page!
•  » » » » 10 months ago, # ^ |   +20 Recursion ...
•  » » » » » 4 months ago, # ^ | ← Rev. 2 →   -26 error:stack overflow,no base case