5-14 电话聊天狂人 (25分)

#include <iostream>
#include <map>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);

	int i;
	long long num;
	map<long long, int> m;

	for(i = 1; i <= 2 * n; i++)
	{
		scanf("%lld", &num);
		m[num]++;
	}

	map<long long, int> ::iterator it, end;
	end = m.end();

	int maxcount = 0, samecount = 0, curcount;
	long long curnum, resnum;

	for(it = m.begin(); it != end; it++)
	{
		curnum = it->first;
		curcount = it->second;

		if(curcount > maxcount)
		{
			maxcount = curcount;
			samecount = 1;
			resnum = curnum;
		}
		else if(curcount == maxcount)
		{
			samecount++;
		}
	}

	if(samecount == 1)
	{
		printf("%lld %d\n", resnum, maxcount);
	}
	else
	{
		printf("%lld %d %d\n", resnum, maxcount, samecount);
	}

	system("pause");
	return 0;
}

 

posted on 2025-11-29 15:00  王景迁  阅读(0)  评论(0)    收藏  举报

导航