public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int n = Integer.parseInt(br.readLine());
for (int tc = 1; tc <= n; tc++) {
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
sb.append(st.nextToken()).append(" ");
int[] arr = new int[20];
int cnt = 0;
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < i; j++) {
if (arr[j] > arr[i]) {
cnt++;
}
}
}
sb.append(cnt).append('\n');
}
System.out.println(sb);
}
출처:https://www.acmicpc.net/problem/10431