Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

16Ms

Posted by woshiliyiyiyiyi at 2012-07-31 16:42:56 on Problem 2028
#include<stdio.h>

int main()
{
	int N, Q;
	int a[1000];
	int i, j, p;
	int count, Max;

	fscanf(stdin, "%d %d", &N, &Q);
	while (N+Q)
	{
		for (i=1; i<100; i++)
			a[i] = 0;

		Max = 0;
		for (i=0; i<N; i++)
		{	
			fscanf(stdin, "%d", &j);
			for (p=0; p<j; p++)
			{
				fscanf(stdin, "%d", &count);
				a[count]++;
				if (count > Max)
				{
					Max = count;
				}
			}
		}

		count = 0;
		for (i=1; i<=Max; i++)
			if (a[i] >= Q)
			{
				count = i;
				Q = a[i] + 1;
			}
		printf("%d\n", count);
		fscanf(stdin, "%d %d", &N, &Q);
	}

	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator