FlyingElephant

Untitled

Apr 18th, 2023
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 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.     multiset<int> T;
  14.     for(int i = 0; i < n; ++i){
  15.         auto it = T.upper_bound(V[i]);
  16.         if(it != T.end()){
  17.             T.erase(it);
  18.         }
  19.         T.insert(V[i]);
  20.     }
  21.     cout << T.size() << "\n";
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment