2 shunfurh shunfurh 于 2017.09.18 11:20 提问

When Can We Meet?

The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meeting. So, in order to settle the meeting date, the chairperson requested every member to send back a list of convenient dates by E-mail. Your mission is to help the chairperson, who is now dedicated to other issues of the contest, by writing a program that chooses the best date from the submitted lists. Your program should find the date convenient for the most members. If there is more than one such day, the earliest is the best.

Input

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

N Q

Here, N, meaning the size of the committee, and Q meaning the quorum, are positive integers. N is less than 50, and, of course, Q is less than or equal to N.

N lines follow, each describing convenient dates for a committee member in the following format.

M Date1 Date2 ... DateM

Here, M 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 100, 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.

Output

For each data set, print a single line containing the date number convenient for the largest number of committee 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.

Sample Input

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

Sample Output

4
5
0
2

1个回答

caozhy
caozhy   Ds   Rxr 2017.10.02 23:46
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
poj2028 When Can We Meet?
2028题要求先读入两个数字,第一个表示总人数,第二个表示开始会议的最低人数,然后依次读入每个人的日期,统计找出最近的符合要求的日子并输出,没有则输出0。 我的思路是将日期统计存入一个数组,数组下标号对应日期,然后扫描数组获取最大值,再扫一遍数组,找到对应的日期输出。感觉还是有点繁,最后应该一边扫一遍就行。 #include #include void main(){ char s[202
1715 When Can We Meet?
#include int main() { int n,q,m,date,max,i; int a[100]; while(scanf("%d%d",&n,&q)&&n){ for(i = 0;i<100;i++) a[i] = 0; while(n--){ scanf("%d",&m); while(m--){ scanf("%d",&date);
POJ2028——When Can We Meet?
When Can We Meet? Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5461   Accepted: 2994 Description The ICPC committee would like to have its meeting as soon
when can we meet POJ-2028
The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly u
(简单)When Can We meet?
#include #include #include #include #include using namespace std; int main() { freopen("fuck.txt","r",stdin); int i,j,k; int n; while (cin>>n>>k,n) { int go[101]={0}; while (n--) { c
POJ2028 When Can We Meet?
仔细看题就知道这个题关键就是找几个数组的公共元素的最大值这里可以用哈希表的方法做出来!重要的事情说三遍哈希表!哈希表!哈希表!原理就是把对应的数值作为下标映射到哈希表里面去,如果每次进来一个数值就对相应的哈希表+1这个不失为一种好方法,对于传统的都可以解决 - -然后给上代码即可了 - -#include <iostream> using namespace std; int hash[101];
2028 When Can We Meet?
<br />这个题虽然挺简单的,但是这个题的思路挺好的,有必要记下来。思路是:将每个人的日期记在一个一维数组里,求得每个日期有多少人参加,从该数组中找第一个最大的值,并且该值必须大于q,则该值就是所要求的值,如果没有这样的值,就输出0。代码如下:<br />#include "stdio.h" #include "string.h" int main() { freopen("in.txt","r",stdin); int n,q; int i,j,k; int m[101]; w
POJ 2028 When Can We Meet?(模拟)
When Can We Meet? Description The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are s
poj 2028 When Can We Meet?
这道题也的确没什么可以写的。。。 AC的代码: #include #include int data[102]; //日期数组 int main() { int N,Q; //N是人数,Q是法定人数 int M; //每个人可以的日期数 int i; int a; //具体的方便日期 int max; //最大人数 int maxInputData; //记录一个
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 >> com