Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int st[1000007];
- int main()
- {
- int g,h,t,y,x,nt=0;
- cin>>t>>y;
- for(g=0;g<t;g++){
- cin>>x;
- st[x]=1;
- }
- for(g=1000000;g>=1; ){
- while(st[g]==0&&g>=0) g--;
- if(st[g]==1) nt++, st[g]=0;
- x=g-y;
- for(h=g-1;h>=x&&h>=1;h--){
- if(st[h]==1){
- if(h-y>=1) st[h-y]=1;
- st[h]=0;
- }
- }
- g=x-1;
- }
- printf("%d\n",nt);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement