SHARE
TWEET

Untitled

anika12 Feb 27th, 2020 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     #include<bits/stdc++.h>
  2.     using namespace std;
  3.  
  4.  
  5.     int main()
  6.     {
  7.  
  8.         int n,t;
  9.         cin>>t;
  10.         for(int i=0;i<t;i++)
  11.         {
  12.             cin>>n;
  13.             vector<int>vec; int count=0;
  14.             for(int j=0;j<n;j++)
  15.             {
  16.                 int a; cin>>a; vec.push_back(a);
  17.             }
  18.  
  19.             for(int k=0;k<n-1;k++)
  20.             {
  21.                 if(vec[k]>vec[k+1]){count++;}
  22.                 else {
  23.                  int mi=*min_element(vec.begin()+k, vec.end());
  24.                   if(vec[k]!=mi)count++;
  25.                 }
  26.             }
  27.             cout<<count<<endl;
  28.  
  29.  
  30.  
  31.  
  32.  
  33.         }
  34.  
  35.  
  36.  
  37.  
  38.     }
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
Top