标签:cep test related sort out man nta tle ini
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 772 Accepted Submission(s): 588
1 //2017-09-22 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 7 using namespace std; 8 9 const int N = 110000; 10 11 int n, arr[N], k; 12 13 int main() 14 { 15 int T; 16 scanf("%d", &T); 17 while(T--){ 18 scanf("%d%d", &n, &k); 19 for(int i = 0; i < n; i++){ 20 scanf("%d", &arr[i]); 21 } 22 sort(arr, arr+n); 23 int ptr = n-1, ans = 0; 24 while(ptr >= 1 && arr[ptr]-arr[ptr-1] <= k){ 25 ptr--; 26 ans++; 27 } 28 printf("%d\n", ans+1); 29 } 30 31 return 0; 32 }
标签:cep test related sort out man nta tle ini
原文地址:http://www.cnblogs.com/Penn000/p/7580601.html