南邮 OJ 1462 Meeting Schedule Arrangement

Meeting Schedule Arrangement

时间限制(普通/Java) :  1000 MS/ 3000 MS          运行内存限制 : 65536 KByte
总提交 : 62            测试通过 : 33 

比赛描述

Mr. Trasapong, the head of Computer Engineering Department, would like to have a meeting as soon as possible to address some issues of the department. However, other members in his department are so busy that it is very difficult to arrange their schedules for the meeting. So, in order to settle the meeting date, he requested every member to send back a list of convenient dates by E-mail. Your mission is to help him by writing a program that chooses the best date from the submitted lists. Your program should find the most convenient date for the most of the members. If there is more than one such day, the earliest is the best.



输入

The input has multiple data sets, each starting with a line containing the number of members in the department and the quorumof the meeting.

NQ

Here, N, meaning the number of the members in the department, and meaning the quorum, are positive integers. is less than 20, and, of course, is less than or equal to N.

lines follow, each describing convenient dates for a member in the following format.M DateDate... DateM

Here, means the number of convenient dates for the member, which is an integer greater than or equal to zero. The remaining items in the line are his/her dates of convenience, which are positive integers less than 31, that is, 1 means tomorrow, 2 means the day after tomorrow, and so on. They are in ascending order without any repetition and separated by a space character. Lines have neither leading nor trailing spaces.

A line containing two zeros indicates the end of the input. 

输出

For each data set, print a single line containing the date number convenient for the largest number of members. If there is more than one such date, print the earliest. However, if no dates are convenient for more than or equal to the quorum number of members, print 0 instead. 

样例输入

3 2
2 1 4
0
3 3 4 8
3 2 
4 1 5 8 9 
3 2 5 9 
5 2 4 5 7 9 
3 3
2 1 4 
3 2 5 9 
2 2 4
3 3
2 1 2 
3 1 2 9 
2 2 4
0 0

样例输出

4


2

提示

Note: quorum means the smallest number of the people who must present at a meeting. 

用于NUPT ACM 2010 Personal Ranking Contest 5


题目来源

ACM-ICPC Thailand Southern Area Programming Contest 2010




#include<iostream>
#include<string>
using namespace std;
int main(){
	int N,Q,M,i,num,a[32],maxIndex;
	while(cin>>N>>Q && (N||Q)){
		for(i=1; i<32; i++){
			a[i] = 0;
		}
		for(i=0; i<N; i++){
			cin>>M;
			while(M--){
				cin>>num;
				a[num]++;
			}
		}
		num = 0;
		maxIndex = 0;
		for(i=1; i<32; i++){
			if(a[i]>num){
				num = a[i];
				maxIndex = i;
			}
		}
		if(num && num>=Q){
			printf("%d\n",maxIndex);
		}else{
			printf("0\n");
		}
	}
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值