L1-034. Like

There is a "Like" function on Weibo, where you can support your favorite blog posts by liking them. Each blog post has some tags that describe its characteristics, and the type of blog post you like also indirectly describes your characteristics. This question requires you to write a program to analyze the characteristics of a person by counting the records of a person's likes.

Input format:

The input gives a positive integer N (<=1000) in the first line, which is the number of blog posts liked by the user. Next N lines, each line gives the feature description of a blog post liked by it, in the format "KF 1 ... F K ", where 1<=K<=10, F i (i=1, .. ., K) is the number of feature labels, we number all feature labels from 1 to 1000. The numbers are separated by spaces.

Output format:

Count the feature tag that appears most frequently in all liked blog posts, and output its number and number of occurrences in one line, with one space between the numbers. If there is a tie, the one with the highest number is output.

Input sample:
4
3 889 233 2
5 100 3 233 2 73
4 3 73 889 2
2 233 123
Sample output:
233 3

Code:

#include<stdio.h>
int a[1010];
intmain()
{
    int i,j,n,m,k,t;
    t=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        for(j=0;j<m;j++)
        {
            scanf("%d",&k);
            a[k]++;
            if(t<a[k])
                t=a[k];
        }
    }
    for(i=1000;i>=1;i--)
    {
        if(t==a[i])
        {
            printf("%d %d",i,t);
            break;
        }
    }
    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325517483&siteId=291194637