fork(1) download
  1. #include <iostream>
  2. #include <unordered_map> //for map<>
  3. using namespace std;
  4. int main()
  5. {
  6. int t,k;
  7. unordered_map<int,int> mp;
  8.  
  9. cin>>t;
  10. for(int i=0;i<t;i++)
  11. {
  12. cin>>k;
  13. mp[k]++;
  14. }
  15.  
  16. //Outputs the duplicate elements in sorted order
  17. for(auto i:mp) //c++!1 extension
  18. {
  19. if(i.second>=2)
  20. cout<<i.first<<" ";
  21. }
  22. cout<<"\n";
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 15240KB
stdin
9
1 1 1 3 3 4 4 1 3
stdout
4 3 1