Advertisement
Guest User

C

a guest
Oct 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int st[1000007];
  4. int main()
  5. {
  6.     int g,h,t,y,x,nt=0;
  7.     cin>>t>>y;
  8.     for(g=0;g<t;g++){
  9.         cin>>x;
  10.         st[x]=1;
  11.     }
  12.     for(g=1000000;g>=1; ){
  13.         while(st[g]==0&&g>=0) g--;
  14.         if(st[g]==1) nt++, st[g]=0;
  15.         x=g-y;
  16.         for(h=g-1;h>=x&&h>=1;h--){
  17.             if(st[h]==1){
  18.                 if(h-y>=1) st[h-y]=1;
  19.                 st[h]=0;
  20.             }
  21.         }
  22.         g=x-1;
  23.     }
  24.     printf("%d\n",nt);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement