-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchop.cpp
56 lines (56 loc) · 1.17 KB
/
chop.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*----------------------------------------
-- Author - Arpit Kumar Singh ------------
-- Dated - Sun Jul 21 22:06:46 IST 2013 --
------------------------------------------*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define mod(a) ((a)<0)?-(a):a
#define getcx getchar_unlocked
using namespace std;
inline void inp( int &n )//fast input function
{
n=0;
int ch=getcx();
int sign=1;
while( ch < '0' || ch > '9' )
{if(ch=='-')sign=-1; ch=getcx();}
while( ch >= '0' && ch <= '9' )
n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
n=n*sign;
}
inline void fastWrite(int a)
{
register char c;
char snum[20];
int i=0;
do
{
snum[i++]=a%10+48;
a=a/10;
}while(a!=0);
i=i-1;
while(i>=0)
putchar_unlocked(snum[i--]);
putchar_unlocked('\n');
}
vector<int>c;
int main(int argc,char *argv[]){
int i,n,d,a;
cin>>n>>d;
for(i=0;i<n;i++){
inp(a);
c.push_back(a);
}
sort(c.begin(),c.end());
a=0;
for(i=1;i<n;i++){
if(c[i]-c[i-1]<=d){
i++;
a++;
}
}
fastWrite(a);
return 0;
}