因为题目中给的数值太大,用hash可能会比较耗时和占内存,可以考虑采用map
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
map <int,int> a;
int main()
{
int m,n;
cin>>m>>n;
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++)
{
int temp;
scanf("%d",&temp);
if(a.find(temp)!=a.end())
a[temp]++;
else
a[temp]=1;
}
}
int ans,max=0;
for (auto it=a.begin();it!=a.end();it++)
{
if(it->second>max)
{
max=it->second;
ans=it->first;
}
}
cout<<ans;
}