mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
34 lines
631 B
C++
34 lines
631 B
C++
|
#include<stdio.h>
|
||
|
#include<math.h>
|
||
|
#include<algorithm>
|
||
|
#include<iostream>
|
||
|
using namespace std;
|
||
|
struct node{
|
||
|
int id;
|
||
|
int v;
|
||
|
}p[33];
|
||
|
bool cmp(node a,node b){
|
||
|
return a.v<b.v;
|
||
|
}
|
||
|
int main(){
|
||
|
int t;
|
||
|
scanf("%d",&t);
|
||
|
int ca=1;
|
||
|
while(t--){
|
||
|
int n;
|
||
|
scanf("%d",&n);
|
||
|
int i;
|
||
|
int ans = 0;
|
||
|
for(i=1;i<=n;i++){
|
||
|
scanf("%d",&p[i].v);
|
||
|
p[i].id = i;
|
||
|
}
|
||
|
sort(p+1,p+1+n,cmp);
|
||
|
for(i=1;i<=n;i++){
|
||
|
ans += abs(p[i].id-i);
|
||
|
}
|
||
|
printf("Case #%d: %d\n",ca++,ans/2);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|