Advertisement
FlyingElephant

Untitled

Apr 18th, 2023
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. int main(){  
  6.     ios::sync_with_stdio(0);
  7.     cin.tie(0);
  8.  
  9.     int n; cin >> n;
  10.     vector<int> V(n);
  11.     for(int i = 0; i < n; ++i) cin >> V[i];
  12.    
  13.     set<int> T;
  14.     T.insert(V[0]);
  15.     for(int i = 1; i < n; ++i){
  16.         auto it = T.lower_bound(V[i]);
  17.         if(it != T.begin()){
  18.             T.erase(--it);
  19.         }
  20.         T.insert(V[i]);
  21.     }
  22.     cout << T.size() << "\n";
  23.     return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement