jakaria_hossain

Hackerreank - countingsort

Jun 15th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  4. int main()
  5. {
  6. int n;
  7. fast()
  8. cin>>n;
  9. int ara[n+1],i,j;
  10. string s;
  11. for(i=0;i<n;i++)
  12. {
  13. cin>>ara[i]>>s;
  14. }
  15. sort(ara,ara+n);
  16. int sum=0,cnt=0,x=ara[0];
  17. for(i=0;i<n;i++)
  18. {
  19. //cout<<x<<endl;
  20. if(x==ara[i])sum++;
  21. else
  22. {
  23. cout<<sum<<" ";
  24. sum++;
  25. x=ara[i];
  26. cnt++;
  27. }
  28. }
  29. if(cnt<100)
  30. {
  31. for(cnt+=1;cnt<=100;cnt++)cout<<sum<<" ";
  32. }
  33. }
Add Comment
Please, Sign In to add comment