jakaria_hossain

Codeforce- Watching tv

Sep 27th, 2018
32
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;
  6. cin>>t;
  7. while(t--)
  8. {
  9. int n,a;
  10. cin>>n;
  11. map<int,int>mp;
  12. int c=0,mx=1000000;
  13. for(int i=0; i<n; i++)
  14. {
  15. string st;
  16. cin>>st>>a;
  17. mp[a]+=1;
  18. if(mp[a]==c)mx=min(a,mx);
  19.  
  20. else if(mp[a]>c)
  21. {
  22. mx=a;
  23. c=mp[a];
  24. }
  25. }
  26. cout<<mx<<endl;
  27.  
  28. }
  29. }
RAW Paste Data