Ankit_132

A

Dec 27th, 2023
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7.  
  8. int main()
  9. {
  10.     _test
  11.     {
  12.         int n;
  13.         cin>>n;
  14.  
  15.         vector<int> a(n);
  16.         for(auto &e: a)     cin>>e;
  17.  
  18.         set<int> st;
  19.         int ans = 0;
  20.  
  21.         for(auto e: a)
  22.         {
  23.             st.insert(e);
  24.             ans += (*st.rbegin() > e);
  25.         }
  26.  
  27.         cout<<ans<<"\n";
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment