fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve(){
  5. int n;
  6. cin>>n;
  7. vector<int> v;
  8. int ans=0;
  9. int max=0;
  10. int temp;
  11. cin>>temp;
  12. v.push_back(temp);
  13. max=temp;
  14. for(int i=1;i<n;i++){
  15. cin>>temp;
  16. v.push_back(temp);
  17. if(temp<max)ans++;
  18. else max=temp;
  19. }
  20. cout<<ans<<endl;
  21. }
  22.  
  23. int main(){
  24. int t;
  25. cin>>t;
  26. while(t--){
  27. solve();
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0s 5308KB
stdin
5
3
3 2 1
3
1 2 3
3
3 3 3
5
3 1 4 5 2
1
1
stdout
2
0
0
2
0