PAT甲级1054 The Dominant Color (20 分)

哈希

#include<iostream>
using namespace std;

const int N=60000*800;
int q[N];
int main()
{
    
    
    int m,n;
    cin>>m>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
    
    
            int x;
            cin>>x;
            q[x]++;
        }
    int max=0;
    for(auto p:q){
    
    
        if(p>max)max=p;
    }
    for(int i=0;i<N;i++)
        if(q[i]==max)max=i;
    cout<<max;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_51928751/article/details/121384523