fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define fast_io ios::sync_with_stdio(0); cin.tie(0);
  5. #define int long long
  6.  
  7. void solve() {
  8. int n;
  9. cin >> n;
  10. vector<int> a(n);
  11.  
  12. for (int i = 0; i < n; i++) cin >> a[i];
  13.  
  14. int mx = a[0];
  15. int removed = 0;
  16.  
  17. for (int i = 1; i < n; i++) {
  18. if (a[i] < mx) {
  19. removed++;
  20. } else {
  21. mx = a[i];
  22. }
  23. }
  24.  
  25. cout << removed << "\n";
  26. }
  27.  
  28. int32_t main() {
  29. fast_io;
  30. int t;
  31. cin >> t;
  32. while (t--) solve();
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5316KB
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