Advertisement
urmisaha

LIS-nlogn

Nov 21st, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int T, N, x, len;
  5.  
  6. int main()
  7. {
  8.     cin>>T;
  9.     while(T--){
  10.         set<int> s;
  11.         len = 0;
  12.         cin>>N;
  13.         for(int i=0; i<N; ++i){
  14.             cin>>x;
  15.             auto st = s.begin();
  16.             if(s.lower_bound(x) == s.end()){
  17.                 s.insert(x);
  18.                 len++;
  19.             }
  20.             else{
  21.                 auto lt = s.lower_bound(x);
  22.                 s.erase(lt);
  23.                 s.insert(x);
  24.             }
  25.         }
  26.         cout<<len<<endl;
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement