code- https://ide.codingblocks.com/s/331350
It works for the test case given in the exmaple
Code not working
ll mx=0,mn=0;
sort(a,a+n);
for(int i=0;i<n/2;i++)
{
mx+=(a[i+n/2]-a[i]);
mn+=(a[2*i+1]-a[2*i]);
}
here is the simple approach to it
in the for loop condition what does i&it mean?
I is index or iterator