O_Egor

var 9

Jun 2nd, 2023
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <unordered_map>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int n;
  10.     cin >> n;
  11.  
  12.     unordered_map<int, int> u_mp;
  13.     vector<int> ans;
  14.  
  15.     for (int i = 0; i < n; ++i)
  16.     {
  17.         int a;
  18.         cin >> a;
  19.         ++u_mp[a];
  20.     }
  21.  
  22.     for (auto& p : u_mp)
  23.     {
  24.         while (p.second--)
  25.         {
  26.             ans.push_back(p.first);
  27.         }
  28.        
  29.     }
  30.  
  31.     for(int i : ans)
  32.     {
  33.         cout << i << ' ';
  34.     }
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment