yzl_rex

对于算法,我只是一个草民!

zoj 1751 When Can We Meet?

#include "iostream"
#include "memory.h"
#include "algorithm"
using namespace std;

int num[100];
int ans[100];

int main()
{
	int committe, quorum, M, i, j, temp1, temp2;
	bool tag;
	while (cin >> committe >> quorum && committe && quorum)
	{
		memset(num, 0, sizeof(num));
		memset(ans, 0, sizeof(ans));
		tag = false;
		for (i = 0; i < committe; i++)
		{
			cin >> M;
			for (j = 0; j < M; j++)
			{
					cin >> num[j];
					ans[num[j]]++;
			}
		}
		temp1 = temp2 = 0;
		for (i = 0; i < 100; i++)
		{
			if (ans[i] >= quorum)
			{
				if (ans[i] > temp1)
				{
					temp1 = ans[i];
					temp2 = i;
				}
				tag = true;
			}
		}
		if (tag)
			cout << temp2 << endl;
		else
			cout << "0" << endl;
	}
}

阅读更多
文章标签: include
个人分类: ZOJ
上一篇zoj 1494 Climbing Worm
下一篇zoj 1730 Crazy Tea Party
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭