L1-034. 点赞

题目地址:https://www.patest.cn/contests/gplt/L1-034

思路:用桶排序的思想,标签作为下标,个数为值,也即求个数最大,值与下标。

注意点:应用桶排序

 1 #include<stdio.h>
 2 int main(){
 3     int N,i,bel[1000]={0};
 4     scanf("%d",&N);
 5     for(i=0;i<N;i++){
 6         int a,j,b;
 7         scanf("%d",&a);
 8         for(j=0;j<a;j++)
 9         {
10             scanf("%d",&b);
11             bel[b-1]++;
12         }
13     }
14     int max,be;
15     max=1;
16     for(i=0;i<1000;i++)
17     {
18         if(max<=bel[i])
19         {
20             max=bel[i];
21             be=i+1;
22         }
23     }
24     printf("%d %d\n",be,max);
25     return 0;
26 } 

 

posted @ 2018-01-18 21:30  爱你的笑  阅读(203)  评论(0编辑  收藏  举报