Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;;
- int n,maxim;
- string str;
- unordered_map<string, int> wordFreq;
- int main()
- {
- int i;
- cin>>n;
- cin.get();
- for(i=0;i<n;++i)
- cin>>str,++wordFreq[str];
- unordered_map<string, int>:: iterator p;
- for(p=wordFreq.begin();p!=wordFreq.end();++p)
- if(p->second>maxim)
- maxim=p->second,str=p->first;
- else
- if(p->second==maxim)
- if(str>p->first)
- str=p->first;
- cout<<str<<' '<<maxim;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement