problem code : MAXDIFF

#include <bits/stdc++.h>

using namespace std;

int main() {

// your code goes here

int t;

cin>>t;

while(t–)

{

long long n,k,sum=0,sum1=0;

cin>>n>>k;

int a[n];

for(int i=0;i<n;i++)

{

cin>>a[i];

sum+=a[i];

}

sort(a,a+n);

for(int i=0;i<k;i++)

sum1+=a[i];

long long h=sum-(2*sum1);

if(h<0)

h=-h;

cout<<h<<endl;

}

return 0;

}