-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1011.cpp
42 lines (41 loc) · 1.02 KB
/
1011.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*************************************************************************
> File Name: 1011.cpp
> Author: heheql
> Mail: [email protected]
> Created Time: 2017年08月08日 星期二 14时06分51秒
************************************************************************/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <math.h>
using namespace std;
int main(){
// freopen("input.txt","r",stdin);
ios::sync_with_stdio(false);
int t;
cin >> t;
while(t--){
int n, k;
cin >> n >>k;
int a[n] = {0};
int maxs = -1;
// map<int,int> mp;
for(int i = 0; i < n; i++){
cin >> a[i];
// mp(a[i])++;
// maxs = max(maxs,a[i]);
}
sort(a, a+n);
int num = 1;
for(int i = n - 1; i > 0; i--){
int temp = abs(a[i],a[i-1]);
if(temp <= k) {
num++;
}else {
break;
}
}
cout << num << endl;
}
return 0;
}