fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main(void) {
  7.  
  8. int dp[1001];
  9. int arr[1001];
  10. int n;
  11.  
  12. cin >> n;
  13.  
  14. int result = -300;
  15.  
  16. for(int i = 0; i <n; i++)
  17. {
  18. cin >> arr[i];
  19. }
  20.  
  21. for(int i = 0; i < n; i++){
  22. dp[i] = 1;
  23. for(int j = 0; j < i; j++){
  24. if(arr[j] > arr[i])
  25. {
  26. dp[i] = max(dp[i],dp[j]+1);
  27. if(result <= dp[i]) result = dp[i];
  28. }
  29. }
  30. }
  31.  
  32. cout << result << endl;
  33.  
  34. }
Success #stdin #stdout 0s 4420KB
stdin
1
1
stdout
-300