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 3 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⋅105, 1≤K≤106) — number of bacteria and intergalactic constant K.

The second line contains n space separated integers a1,a2,…,an (1≤ai≤106) — 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.

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
LL a[300010];
int main(){LL m, n, i, j, l;while(scanf("%lld%lld",&n, &m) != EOF){map<int, int> mp;memset (a, 0, sizeof(a));for (i = 0; i < n; i ++){scanf("%lld", &a[i]);mp[a[i]] ++;}sort(a, a + n);l = unique(a, a + n) - a;for (i = 1 ; i < l; i ++){if(a[i] > a[i-1] && a[i-1] + m >= a[i]){n = n - mp[a[i-1]];}}printf("%lld\n", n);}return 0;
}

Micro-World相关推荐

  1. 用Micro:bit做浇灌系统

    利用Micro:bit结合[土壤湿度感测棒]做一个简单的浇灌系统 一.测试土壤湿度感测棒 •材料:土壤湿度感测棒 (万能的淘宝上可以找到) •连接:将[土壤湿度感测棒]的一端接P0.另一端接GND 简 ...

  2. Caliburn.Micro 资源随时添加

    Caliburn.Micro – Hello World http://buksbaum.us/2010/08/01/caliburn-micro-hello-world/ http://blog.c ...

  3. 在.Net Micro Framework中显示汉字

    摘要:MF平台支持的字体是专有格式,扩展名为tinyfnt,需要用专门的转化工具才能把windows平台上的字体转换为tinyfnt字体.在.Net Micro Framework SDK中提供了一个 ...

  4. 清华芯片研究再获顶会MICRO加持:软件定义芯片团队出品,最佳论文提名后又一突破...

    杨净 发自 凹非寺  量子位 报道 | 公众号 QbitAI 最近,第53届国际微架构大会(MICRO)在线上顺利召开. 作为计算机体系结构四大顶级会议,清华大学魏少军.刘雷波团队有两篇入选该会议论文 ...

  5. .NET Micro Framework常见问题问答

    问:.NET Micro Framework是什么? 答:请参见:http://blog.csdn.net/yefanqiu/article/details/5711770 官方网站:http://w ...

  6. 模型评估指标micro avg、macro avg和weighted avg的计算方式及区别

    模型评估指标micro avg.macro avg和weighted avg的计算方式及区别-技术圈

  7. 53年来国内唯三,MindSpore加速昇腾芯片论文获国际顶会MICRO最佳论文提名

    点击上方,选择星标或置顶,不定期资源大放送! 阅读大概需要10分钟 Follow小博主,每天更新前沿干货 "研究芯片光砸钱不行,要砸数学家.物理学家." 任正非今年5月在接受< ...

  8. Payara基金会发布全面支持MicroProfile 2.0的5.183版Payara Server和Payara Micro

    Payara基金会最近发布了5.183版Payara Server和Payara Micro,其中包含大量新功能.升级和Bug修复,并开始全面支持MicroProfile 2.0和Java EE 8. ...

  9. 牌类游戏使用微服务重构笔记(四): micro框架使用经验

    项目依赖 推荐使用go module, 我选择go module的最主要原因是足够简单,可以脱离gopath,就跟写nodejs一样,随便在一个地方新建一个文件夹就可以撸代码了,clone下来的源码也 ...

  10. .NET Micro Framework动态调用C/C++底层代码(原理篇)

    .NET Micro Framework和WinCE系统不同,从应用开发角度来说,仅支持C#开发(从V4.2版本开始,才支持VB.NET开发),而不像WinCE应用开发,既可以用C#/VB.Net,也 ...

最新文章

  1. mysql 不同连接的事务 会嵌套_MySQL——事务
  2. 第一章初始mybatis框架
  3. OpenCV与图像处理学习十三——Harris角点检测(含代码)
  4. php开发视频播放顺序,请问关于php代码运行顺序问题
  5. 4个独立按键实现对数码管数字显示的加减清零等
  6. 疯狂Java学习笔记(72)-----------大话程序猿面试
  7. Express框架学习笔记-基础
  8. 【软考软件评测师】2018综合知识历年真题
  9. 如何下载STM32某型号MCU的数据手册(datasheet)
  10. 计算机专业期末试卷分析,计算机期末试卷分析
  11. zipArchive not found
  12. 百度 bos php,GitHub - SwimmingTiger/BOSFS: PHP流包装器:百度开放云对象存储文件系统(BCE BOS File System)...
  13. jdk,j2sdk,j2eesdk,jre 的区别和联系
  14. sht21 c语言程序,SHT20,SHT21程序代码.pdf
  15. 转: 诺贝尔奖得主:东亚教育浪费了太多生命
  16. Iphone连接Openwrt的IPSEC服务器
  17. C语言学习一些指针随笔记
  18. 【U8】固定资产模块卡片管理栏目设置中没有“凭证号”栏目
  19. Linux线程ID与内核LWP的关系
  20. jq中如何调用vue中的方法

热门文章

  1. Canvas制作经典贪吃蛇
  2. android开发2021,2021年高校邦Android手机软件快速开发App Inventor【2021秋】满分答案...
  3. 【不可思议的CANVAS】画一只会跟着鼠标走的小狗
  4. php设置上传文件大小限制
  5. 写一个微信pc端,还能发朋友圈!
  6. HTTP请求方式中8种请求方法(简单介绍)
  7. ES6 新增数组的方法使用介绍
  8. Java 加static修饰符的含义
  9. intel quark_离线工作的搜索引擎-OpenGenus Quark
  10. touch的双击唤醒如何实现