fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <cstring>
  5. #include <math.h>
  6. #include <algorithm>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11. int n;
  12. cin >> n;
  13. vector <int> a;
  14. vector <int> d;
  15. for (int i = 0; i < n; i++) {
  16. int k;
  17. cin >> k;
  18. a.push_back(k);
  19. }
  20. for (int i = 0; i < n; i++) {
  21. d.push_back(1);
  22. for (int j = 0; j < i; j++) {
  23. if (a[j] < a[i]) {
  24. d[i] = max(d[i], d[j] + 1);
  25. }
  26. }
  27. }
  28. sort(d.begin(), d.end());
  29. cout << d[n - 1];
  30. }
Success #stdin #stdout 0s 3476KB
stdin
6
3 29 5 5 28 6
stdout
3