KiK0S

Untitled

Jul 28th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1.  
  2. inline void solve() {
  3.     init();
  4.     vector<int> q = {1, 2, 3, 4, 5};
  5.     cout << *lower_bound(q.begin(), q.end(), 3) << '\n'; // first >=
  6.     cout << *upper_bound(q.begin(), q.end(), 4) << '\n'; // first >
  7.     cout << *(upper_bound(q.begin(), q.end(), 1) - 1) << '\n'; // last <=
  8.     cout << *(lower_bound(q.begin(), q.end(), 2) - 1) << '\n'; // last <
  9.     cout << *upper_bound(q.rbegin(), q.rend(), 3, [](int a, int b){  //last <, but another words
  10.         return a > b;
  11.     }) << '\n';
  12. }
  13.  
  14. /*
  15. output
  16. 3
  17. 5
  18. 1
  19. 1
  20. 2
  21. */
Advertisement
Add Comment
Please, Sign In to add comment