Talk is cheap. Show me the code. —— Linus Torvalds
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 1010;
int main()
{
//freopen("i.txt", "r", stdin);
int t, n, a[MAX], ans = 0;
scanf("%d", &t);
while(t--)
{
ans = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", &a[i]);
for(int i = 1; i < n; i++)
for(int j = 0; j < i; j++)
if(a[j] <= a[i]) ans++;
printf("%d\n", ans);
}
return 0;
}