Advertisement
Saleh127

CF 1203E

Aug 11th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);cout.tie(0);
  7.  
  8. int a[200000]={0},c[200000],d,e=0,f=0,i,j,k,l;
  9. cin>>d;
  10. for(i=0;i<d;i++)
  11. {
  12. cin>>c[i];
  13. a[c[i]]++;
  14. f=max(f,c[i]);
  15. }
  16. for(i=1;i<=f+5;i++)
  17. {
  18. if(a[i-1])
  19. {
  20. a[i-1]--;
  21. e++;
  22. }
  23. else if(a[i])
  24. {
  25. a[i]--;
  26. e++;
  27. }
  28. else if(a[i+1])
  29. {
  30. a[i+1]--;
  31. e++;
  32. }
  33. }
  34. cout<<e<<endl;
  35. return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement