fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(false);
  7. cin.tie(0);
  8.  
  9. int n;
  10. cin >> n;
  11.  
  12. vector<int> a(n);
  13. for (int i = 0; i < n; i++)
  14. {
  15. cin >> a[i];
  16. }
  17.  
  18. int ctr = 1, maxLength = 1;
  19.  
  20. for (int i = 1; i < n; i++)
  21. {
  22. if (a[i] >= a[i - 1])
  23. {
  24. ctr++;
  25. maxLength = max(maxLength, ctr);
  26. }
  27. else
  28. ctr = 1;
  29. }
  30.  
  31. cout << maxLength;
  32. }
Success #stdin #stdout 0.01s 5284KB
stdin
6
2 2 1 3 4 1
stdout
3