Kode C untuk Konverter Algoritma Online
#include<bits/stdc++.h>
using namespace std;
int main()
int n,i,sum=0;
cin>>n;
int arr[n];
for(i=0;i<n;i++)
cin>>arr[i];
sort(arr,arr+n);
for(i=0;i<n;i++)
{
int z= arr[n-i-1]-(i+1);
//cout<<z<<" ";
//cout<<abs(z);
sum=sum+abs(z);
}
cout<<sum;
return 0;
cout<<"swap(l,r);
}
Disturbed Dogfish