fork download
  1. #include <bits/stdc++.h>
  2. #define lli long long int
  3. using namespace std;
  4.  
  5. typedef multimap<int,int>::iterator it;
  6. multimap<int , int> score;
  7. map<int , it> num;
  8.  
  9. void increase(int x)
  10. {
  11. it score_it;
  12. map<int , it>::iterator num_it = num.find(x);
  13. if ( num_it == num.end() )
  14. {
  15. num[x] = score.insert( make_pair( 1 , x ) );
  16. }
  17. else
  18. {
  19. score_it = (num_it->second);
  20. int cnt = score_it->first + 1;
  21. score.erase( score_it );
  22. num_it->second = score.insert( make_pair( cnt , x ) );
  23. }
  24. }
  25.  
  26. int getMin()
  27. {
  28. return score.begin()->second;
  29. }
  30.  
  31. int main()
  32. {
  33. ios_base::sync_with_stdio(false);
  34. int n , m;
  35.  
  36. cin>>n>>m;
  37. for (int i=0 ; i<n ; i++)
  38. {
  39. for (int j=0 ; j<m ; j++)
  40. {
  41. int x; cin>>x;
  42. increase(x);
  43. }
  44.  
  45. cout<<getMin()<<"\n";
  46. }
  47.  
  48. return 0;
  49. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
Standard output is empty