//#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") //#pragma GCC optimize("unroll-loops") #include #define N 100005 #define inf 2147483647 #define LL long long using namespace std; int T,n,m,ans,a[N],lst; struct FastIO{ static const int S=1048576; char buf[S],*L,*R;int stk[20],Top;~FastIO(){clear();} inline char nc(){return L==R&&(R=(L=buf)+fread(buf,1,S,stdin),L==R)?EOF:*L++;}inline void clear(){fwrite(buf,1,Top,stdout);Top=0;} inline void pc(char ch){Top==S&&(clear(),0);buf[Top++]=ch;}inline void endl(){pc('\n');} FastIO& operator >> (char&ch){while(ch=nc(),ch==' '||ch=='\n');return *this;} templateFastIO& operator >> (T&ret){ ret=0;int f=1;char ch=nc();while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=nc();} while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=nc();}ret*=f;return *this; } FastIO& operator >> (char* s){int Len=0;char ch=nc();while(ch!='\n'){*(s+Len)=ch;Len++;ch=nc();}} templateFastIO& operator << (T x){ if(x<0){pc('-');x=-x;}do{stk[++stk[0]]=x%10;x/=10;}while(x); while(stk[0]) pc('0'+stk[stk[0]--]);return *this; } FastIO& operator << (char ch){pc(ch);return *this;} FastIO& operator << (string str){int Len=str.size()-1;for(stk[0]=0;Len>=0;Len--) stk[++stk[0]]=str[Len];while(stk[0]) pc(stk[stk[0]--]);return *this;} }fin,fout; int main(){ // freopen("data.in","r",stdin); // freopen("jxc.out","w",stdout); fin>>T;while(T--){ fin>>n>>m;for(register int i=1;i<=n;i++) fin>>a[i]; sort(a+1,a+n+1),ans=0,lst=-inf;for(register int i=1;i<=n;i++){ if(a[i]-m>lst){lst=a[i]-m,ans++;continue;} if(a[i]+m<=lst) continue; lst++,ans++; } cout<