SHARE
TWEET

Untitled

a guest Jul 16th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     ios_base::sync_with_stdio(false);
  8.     cin.tie(NULL);
  9.  
  10.     int n; cin >> n;
  11.  
  12.     unsigned int a[n];
  13.     for(int i = 0; i < n; i++)
  14.     {
  15.         cin >> a[i];
  16.     }
  17.  
  18.     int counter = 1;
  19.     vector<int> v;
  20.  
  21.     int temp = a[0];
  22.     for(int i = 1; i < n; i++)
  23.     {
  24.         if(temp <= a[i])
  25.         {
  26.             temp = a[i-1];
  27.             counter++;
  28.         }
  29.  
  30.         else
  31.         {
  32.             temp = a[i];
  33.             v.push_back(counter);
  34.             counter = 1;
  35.         }
  36.     }
  37.  
  38.     v.push_back(counter);
  39.  
  40.     int maxCount = v[0];
  41.     for(int i = 1; i < v.size(); i++)
  42.     {
  43.         if(maxCount < v[i])
  44.             maxCount = v[i];
  45.     }
  46.  
  47.     cout << maxCount;
  48.  
  49.     return 0;
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top