fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. map<int,int> mp;// when we write normal map that means ordered and unordered is unordered map
  6. int n;
  7. cin>>n;
  8. vector<int> arr(n);
  9. for(int i=0;i<n;i++)
  10. {
  11. cin>>arr[i];
  12. mp[arr[i]]++;
  13. }
  14. for(auto a: mp)
  15. {
  16. cout<<a.first<<" "<<a.second<<endl;
  17. }
  18. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
0 5334