思维~

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+;
int a[maxn];
int b[maxn];
int N;
int main () {
int T;
scanf ("%d",&T);
while (T--) {
scanf ("%d",&N);
for (int i=;i<=N;i++) {
scanf ("%d",&a[i]);
b[i]=a[i];
}
sort (b+,b+N+);
int ans=;
for (int i=N;i>=;i--) {
if (a[i]==b[i+ans]) continue;
else ans++;
}
printf ("%d\n",ans);
}
return ;
}
05-27 00:45