fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin>>n;
  7. int v[n];
  8. for(int i=0;i<n;i++)
  9. {
  10. cin>>v[i];
  11. }
  12. map<int,int> m;
  13. for(auto x : v)
  14. {
  15. m[x]++;
  16. }
  17. for(auto i : m)
  18. {
  19. cout<<i.first<<" "<<i.second<<"\n";
  20. }
  21. // your code goes here
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5532KB
stdin
10
1 2 4 3 4 3 3 6 1 1 
stdout
1 3
2 1
3 3
4 2
6 1