地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=254

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #define N 200010
 4 int a[N];
 5 int cmp(void const *a,void const *b)
 6 {
 7     return *(int *)a-*(int *)b;
 8 }
 9 int main()
10 {
11     int T,max,count,maxnum,n,i;
12     scanf("%d",&T);
13     while(T--)
14     {
15         scanf("%d",&n);
16         for(i=0;i<n;i++)
17             scanf("%d",&a[i]);
18         qsort(a,n,sizeof(int),cmp);
19         for(i=1,max=a[0],count=1,maxnum=1;i<n;i++)
20         {
21             if(a[i]==a[i-1])
22             {
23                 count++;
24                 if(count>maxnum) 
25                 {
26                     maxnum=count;
27                     max=a[i-1];
28                 }
29                     
30             }
31             else count=1;        
32         }
33         printf("%d\n",max);
34     }
35     //system("pause");
36     return 0;
37 }
   

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2021-06-10
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
猜你喜欢
  • 2022-01-26
  • 2022-12-23
  • 2022-02-14
  • 2021-08-23
  • 2021-06-28
  • 2022-12-23
  • 2021-12-03
相关资源
相似解决方案