Why am I getting WA in this problem

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll T;
cin >> T;
while(T–){
ll n, k;
cin >> n >> k;
vector arr;
for(ll i = 0 ; i < n ; i++){
ll x;
cin >> x;
arr.push_back(x);
}
sort(arr.begin(),arr.end());
ll minn = INT_MAX;
for(ll i = 0 ; i < n-k ; i++){
minn = min(arr[k+i-1]-arr[i], minn);
}

    cout << minn << endl;

}
return 0;
}

problem : Contest Page | CodeChef