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