fork download
  1. #include <iostream>
  2. #include <unordered_map>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8.  
  9. int t;
  10. cin >>t ;
  11. while(t--)
  12. {
  13. unordered_map<int, int> mp;
  14. int n;
  15. cin >> n;
  16.  
  17. while(n--)
  18. {
  19. int num;
  20. cin >>num;
  21. if(mp.find(num)== mp.end())
  22. {
  23. mp[num] = 1;
  24. }
  25. else
  26. {
  27. mp[num]++;
  28. }
  29. }
  30.  
  31. for(auto it = mp.begin(); it!=mp.end(); it++)
  32. {
  33. cout << it->first << " " << it->second <<endl;
  34. }
  35. }
  36.  
  37.  
  38.  
  39.  
  40. //code
  41. return 0;
  42. }
Time limit exceeded #stdin #stdout 5s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty