// #pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i, l, r) for(int i=l; i<=r; i++) #define dow(i, l, r) for(int i=l; i>=r; i--) #define fi first #define se second #define pb push_back #define mp make_pair #define clr(x, c) memset(x,c,sizeof(x)) typedef long long ll; typedef unsigned long long ull; typedef pair Pii; inline int read() { int x=0,f=0; char ch=getchar(); while (ch<'0' || '9'n) // struct edge{int y; edge *n;} e[maxm], *fir[maxn], *pt=e; // void AddE(int x, int y){pt->y=y, pt->n=fir[x], fir[x]=pt++;} // =========================== 快速幂 // inline int pow(int x, int t) { // int g = 1; // while (t) { // if (t&1) g = 1LL*g*x%Q; // x = 1LL*x*x%Q; // t >>= 1; // } // return g; // } // ====================================================== 主程序 #define maxn 100009 int a[maxn]; int main() { int T = read(); while (T--) { int n = read(), k = read(); rep(i, 1, n) a[i] = read(); sort(a+1, a+1+n); int now = -2000000000, ans = 0; rep(i, 1, n) { if (now < a[i] - k) now = a[i] - k, ans++; else if (a[i] - k <= now && now < a[i] + k) now++, ans++; else if (now == a[i] + k) now = now; } printf("%d\n", ans); } return 0; }