Advertisement
sherry_ahmos

Untitled

Jul 17th, 2022
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4. #include <string>
  5. #include <queue>
  6. #include <map>
  7. #include <set>
  8. #include <string>
  9. #include <algorithm>
  10. #include <cmath>
  11.  
  12. using namespace std;
  13. #define ll long long
  14. #define nl endl
  15. #define cy cout << "YES\n"
  16. #define cn cout << "NO\n"
  17. #define sz s.size()
  18.  
  19. void sherry()
  20. {
  21.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  22. #ifndef ONLINE_JUDGE
  23.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  24. #endif
  25. }
  26. int main()
  27. {
  28.     sherry();
  29.     ll n;
  30.     cin >> n;
  31.     deque<ll> dq;
  32.     vector<ll> v(n);
  33.     for (ll i = 0; i < n; i++)
  34.     {
  35.         cin >> v[i];
  36.     }
  37.     sort(v.begin(), v.end(), greater<ll>());
  38.     for (ll i = 0; i < n; i++)
  39.     {
  40.         if (v[i] != v[i - 1])
  41.         {
  42.             dq.push_front(v[i]);
  43.         }
  44.         else
  45.         {
  46.             dq.push_back(v[i]);
  47.         }
  48.     }
  49.     for (auto &i : dq)
  50.         cout << i << " ";
  51.     return 0;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement