A1054 The Dominant Color [map]

在这里插入图片描述

#include<vector>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<set>
#include<map>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	int n, m, col;
	scanf("%d%d",&n,&m);
	map<int, int>count;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			scanf("%d",&col);
			if (count.find(col) != count.end())
				count[col]++;
			else
				count[col] = 1;
		}
	}
	int k = 0, max = 0;
	for (map<int,int>::iterator it=count.begin();it!=count.end();it++)
	{
		if (it->second > max)
		{
			k = it->first;
			max = it->second;
		}
	}
	cout << k << endl;
}
posted @ 2020-07-21 23:27  _Hsiung  阅读(41)  评论(0编辑  收藏  举报