fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int N[40001];
  7. int cache[40001];
  8. int main(void)
  9. {
  10. int code;
  11. cin>>code;
  12. for(int i = 1; i<=code; i++)
  13. cin>>N[i];
  14.  
  15. int result = 0;
  16. memset(cache, -1, sizeof(cache));
  17. for(int i = 1; i<=code; i++)
  18. {
  19. if(cache[i] != -1) continue;
  20. cache[i] = 1;
  21. for(int j = i; j>=1; j--)
  22. {
  23. if(N[i] > N[j] && cache[i] < cache[j] +1){
  24. cache[i] = cache[j] + 1;
  25. if(result < cache[i]) result = cache[i];
  26. }
  27. }
  28. }
  29.  
  30. cout<<result<<endl;
  31. return 0;
  32. }
Success #stdin #stdout 0s 4548KB
stdin
3
3 2 1
stdout
0