sacgajcvs

Untitled

Oct 17th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. ll fun(vector<ll>& arr)
  2. {
  3. if (arr.size() == 0)
  4. return 0;
  5. vector<ll> new_arr;
  6. new_arr.pb(arr[0]);
  7. for (ll i = 1; i < arr.size(); i++) {
  8.  
  9. if (arr[i] < new_arr[0]) {
  10. new_arr[0] = arr[i];
  11. } else if (arr[i] > new_arr.back()) {
  12. new_arr.pb(arr[i]);
  13. } else {
  14. ll ps = lower_bound(new_arr.begin(),new_arr.end(),arr[i]) - new_arr.begin();
  15. new_arr[ps] = arr[i];
  16. }
  17. }
  18. return sz(new_arr);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment