fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n,t;
  6. cin>>n;
  7. unordered_map<int,int>mp;
  8. for(int i=0;i<n;i++){
  9. cin>>t;
  10. mp[t]++;
  11. }
  12. int mn=INT16_MAX,mx=0,mn1=mn,mx1=0;
  13. for(auto &it:mp){
  14. if(it.second<mn){
  15. mn1=it.first;
  16. mn=it.second;
  17. }
  18. if(it.second>mx){
  19. mx1=it.first;
  20. mx=it.second;
  21. }
  22. }
  23. cout<<mx1<<" "<<mn1<<"\n";
  24. return 0;
  25. }
Success #stdin #stdout 0s 5320KB
stdin
5
2 6 2 3 1
stdout
2 3