Problem description

You have a Petri dish with bacteria and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any microscope nearby, so you can't watch them.You know that you have n bacteria in the Petri dish and size of the i-th bacteria is ai. Also you know intergalactic positive integer constant K.

The i-th bacteria can swallow the j-th bacteria if and only if ai>aj and ai≤aj+K. The j-th bacteria disappear, but the i-th bacteria doesn't change its size. The bacteria can perform multiple swallows. On each swallow operation any bacteria i can swallow any bacteria j if ai>aj and ai≤aj+K. The swallow operations go one after another.For example, the sequence of bacteria sizes a=[101,53,42,102,101,55,54] and K=1. The one of possible sequences of swallows is: [101,53,42,102,101,55,54] →[101,53,42,102,55,54]→ [101,42,102,55,54]→ [42,102,55,54]→ [42,102,55]. In total there are 33 bacteria remained in the Petri dish.

Since you don't have a microscope, you can only guess, what the minimal possible number of bacteria can remain in your Petri dish when you finally will find any microscope.

Input

The first line contains two space separated positive integers n and K (1≤n≤2⋅10^5, 1≤K≤10^6) — number of bacteria and intergalactic constant K.

The second line contains n space separated integers a1,a2,…,an (1≤ai≤10^6) — sizes of bacteria you have.

Output

Print the only integer — minimal possible number of bacteria can remain.

Examples

Input

7 1
101 53 42 102 101 55 54

Output

3

Input

6 5
20 15 10 15 20 25

Output

1

Input

7 1000000
1 1 1 1 1 1 1

Output

7

Note

The first example is clarified in the problem statement.In the second example an optimal possible sequence of swallows is: [20,15,10,15,20,25] → [20,15,10,15,25] →[20,15,10,25]→ [20,15,25] → [20,25]→ [25].In the third example no bacteria can swallow any other bacteria.

解题思路:题目的意思就是只要ai>aj且ai-aj<=K,aj就可以被吞噬掉(标记为-1)。做法:先排序;然后用两个变量模拟指针i,j指向当前元素的位置,初始值都为0。如果a[j]-a[i]==0,j后移一位,即j++;如果a[j]-a[i]>k,i就往后移一位,即i++;否则(a[j]-a[i]<=K)将a[i]标记为-1,然后i++;最后统计数组a中值不是-1的个数,即为最小剩余细菌的个数,水过。

AC代码:

 #include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+;
int n,k,i,j,m,tmp,a[maxn];
int main(){
cin>>n>>k;m=i=j=;
for(int p=;p<n;++p)cin>>a[p];
sort(a,a+n);
while(i<n&&j<n){
tmp=a[j]-a[i];
if(tmp==)j++;
else if(tmp>k)i++;
else{a[i]=-;i++;}
}
for(int p=;p<n;++p)
if(a[p]!=-)m++;
cout<<m<<endl;
return ;
}

最新文章

  1. JSON的简单例子
  2. poj 2115 Looooops
  3. 深入浅出jsonp
  4. poj 1061 扩展欧几里得解同余方程(求最小非负整数解)
  5. ADO.NET基础(增删改查)
  6. iOS H5 容器的一些探究(一):UIWebView 和 WKWebView 的比较和选择
  7. bzoj3926
  8. SKPhysicsJoint类
  9. YBC中国国际青年创业计划
  10. MyEclipse 怎样手动编译整个项目
  11. ADO面板上的控件简介
  12. Angular - - angular.forEach、angular.extend
  13. Java面试宝典笔记录
  14. python 零基础学习之路 02-python入门
  15. HTML表单 CSS样式
  16. html设置 hight100%问题
  17. POJ3734Blocks(递推+矩阵快速幂)
  18. 【DWM1000】 非官方开源定位代码bitcraze
  19. Eclipse中Maven插件配置
  20. LoadRunner-循环

热门文章

  1. vue04 组件化开发 Vue自动化工具
  2. iOS 中plist文件中配置key值冲突的现象
  3. MySQL多表连接操作
  4. Django REST framework 自定义(认证、权限、访问频率)组件
  5. SpringMVC demo 小例子,实现简单的登录和注册
  6. ubuntu 14.04 gcc/g++版本降低
  7. NOI2017爆零记[AFO]
  8. 【ACM】hdu_zs3_1007_Rails_201308100802
  9. python 执行环境
  10. MVC.Net:将Reponse Redirect从Get变为Post