fork download
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int count(int *a, int first, int last);
  6.  
  7. int main()
  8. {
  9. int n, *A, num, max;
  10. cin >> n;
  11. A=new int[n];
  12.  
  13. for(int i=0; i<n; i++)
  14. {
  15. cin >> num;
  16. A[i]=num;
  17. }
  18.  
  19. max=count(A, 0, n);
  20.  
  21. for(int i=1; i<n; i++)
  22. {
  23. if(max<count(A, i, n))
  24. max=count(A, i, n);
  25. }
  26.  
  27. cout << max;
  28.  
  29. }
  30.  
  31. int count(int *a, int first, int last)
  32. {
  33. int count=0, temp;
  34.  
  35. temp=first;
  36. for(int i=first; i<last; i++)
  37. {
  38. if(temp<a[i])
  39. {
  40. count++;
  41. temp=a[i];
  42. }
  43. }
  44.  
  45. return count;
  46. }
Success #stdin #stdout 0s 15232KB
stdin
4
1 4 2 3
stdout
2