Advertisement
a53

Colegi

a53
Nov 5th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;;
  3. int n,maxim;
  4. string str;
  5. unordered_map<string, int> wordFreq;
  6.  
  7. int main()
  8. {
  9. int i;
  10. cin>>n;
  11. cin.get();
  12. for(i=0;i<n;++i)
  13. cin>>str,++wordFreq[str];
  14. unordered_map<string, int>:: iterator p;
  15. for(p=wordFreq.begin();p!=wordFreq.end();++p)
  16. if(p->second>maxim)
  17. maxim=p->second,str=p->first;
  18. else
  19. if(p->second==maxim)
  20. if(str>p->first)
  21. str=p->first;
  22. cout<<str<<' '<<maxim;
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement