fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. unordered_map<int,int> mp;
  6. int n; cin>>n;
  7.  
  8. for(int i=0;i<n;i++)
  9. {int temp; cin >> temp; mp[temp]++;}
  10. int a=0 ,b=0,c=0,d=INT_MAX;
  11. for(auto x : mp){
  12. if(x.second > b) a=x.first,b=x.second;
  13. if(x.second<d) c=x.first,d=x.second;
  14. }
  15. cout<<a<<" "<<b<<endl<<c <<" "<<d;
  16. }
  17.  
  18.  
Success #stdin #stdout 0s 5320KB
stdin
10
1 2 3 1 2 3 1 2 9 10
stdout
1 3
10 1