WRONG ANSWER PLEASE CHECK


Please check

@rachitbansal2500 this is the correct app

int main() {
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
long long int mi=0,ma=0;
for(int i=0;i<n/2;i++)
{
ma+=abs(a[n-i-1]-a[i]);
}
for(int i=0;i<n-1;i+=2)
{
mi+=abs(a[i+1]-a[i]);
}
cout<<mi<<" "<<ma<<endl;
}
return 0;
}
i dont think you are doing this exactly

I am exactly doing this, can you please point out the mistake. The code was even working for the example case.

@rachitbansal2500 corrected code

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.