fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n;
  7. cin>>n;
  8. int arr[n];
  9. int dp[n];
  10. for(int i=0; i<n; ++i)
  11. {
  12. cin>>arr[i];
  13. }
  14. for(int i=0; i<n; i++)
  15. {
  16. dp[i] = 1;
  17. }
  18. for(int i = 1; i<n; ++i)
  19. {
  20. for(int j = 0; j < i; ++j)
  21. {
  22. if(dp[i] == dp[j] && arr[i] > arr[j])
  23. {
  24. dp[i] = dp[j] + 1;
  25. }
  26. }
  27. }
  28. int max = 0;
  29. for(int i=0; i<n; ++i)
  30. {
  31. if(dp[i] > max)
  32. {
  33. max = dp[i];
  34. }
  35. }
  36.  
  37. cout<<max;
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0.49s 4480KB
stdin
Standard input is empty
stdout
47