#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; #define int long long const int maxn = 1e6 + 7; const int INF = (1 << 31) - 1; const int mod = 998244353; int a[maxn], b[maxn]; void work() { int n, k; cin >> n >> k; for (int i = 1; i <= n; ++i)cin >> a[i]; sort(a + 1, a + 1 + n); int mx = a[1] - k - 1; ll cnt = 0; b[0] = INF; for (int i = 1; i <= n; ++i) { b[i] = min(max(mx + 1, a[i] - k), a[i] + k); mx = b[i]; if (b[i] != b[i - 1])cnt++; } cout << cnt << '\n'; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T; cin >> T; for (int i = 1; i <= T; ++i) { // cout << "Case #" << i << ": "; work(); } }