fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fi first
  5. #define se second
  6. const int MAXN = 1e6+7;
  7. int a[MAXN];
  8.  
  9. int main()
  10. {
  11. ios_base::sync_with_stdio(0);
  12. cin.tie(0);
  13. int n;
  14. cin >> n;
  15. for(int i = 1;i <= n;i++) {
  16. cin >> a[i];
  17. }
  18. vector<int> f;
  19. for(int i = 1;i <= n;i++) {
  20. int p = lower_bound(f.begin(),f.end(),a[i]) - f.begin();
  21. if(p == f.size()) f.push_back(a[i]);
  22. else f[p] = a[i];
  23. }
  24. cout << f.size();
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
1