Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline void solve() {
- init();
- vector<int> q = {1, 2, 3, 4, 5};
- cout << *lower_bound(q.begin(), q.end(), 3) << '\n'; // first >=
- cout << *upper_bound(q.begin(), q.end(), 4) << '\n'; // first >
- cout << *(upper_bound(q.begin(), q.end(), 1) - 1) << '\n'; // last <=
- cout << *(lower_bound(q.begin(), q.end(), 2) - 1) << '\n'; // last <
- cout << *upper_bound(q.rbegin(), q.rend(), 3, [](int a, int b){ //last <, but another words
- return a > b;
- }) << '\n';
- }
- /*
- output
- 3
- 5
- 1
- 1
- 2
- */
Advertisement
Add Comment
Please, Sign In to add comment