fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int n, i, j, a[1001], lim, max = 0, count;
  6. scanf("%d", &n);
  7.  
  8. for(i=1; i<=n; i++)
  9. {
  10. scanf("%d", &a[i]);
  11. lim = 1001;
  12. count = 1;
  13. for(j=1; j<i; j++)
  14. {
  15. if(a[j] > a[i] && a[j] < lim)
  16. {
  17. count++;
  18. lim = a[j];
  19. }
  20. }
  21. if (count > max)
  22. max = count;
  23. }
  24. printf("%d", max);
  25. }
Success #stdin #stdout 0s 9424KB
stdin
4
2 4 3 1
stdout
2