No. Statistical time limit: 2000 MS | memory limit: 65535 KB difficulty: 2
-
Description
-
Zyc is boring recently, so he wants to make a boring statistical analysis. He counted the addresses of all the students (zyc converted the addresses into code), and then he wanted to know the most students in that place (if there are multiple students with the most students, ).
-
Input
-
Enter a positive integer T (0 <T <= 11) in the first line to indicate that there are T groups of test data.
Enter a positive integer N (0 <N <200000) In the first line of each group of test data to indicate that there are N numbers, and then enter N encodings (the encoding is composed of digits and less than 10 digits)
-
Output
-
The output of each group of data occupies the maximum number of output rows
-
Sample Input
-
1512345 456 45 78 78
-
Sample output
-
78
#include<cstdio>#include<algorithm>#include<iostream>using namespace std;int main(){int n,m,i,ff,count=0;int a[200005];scanf("%d",&n);while(n--){int max=0;scanf("%d",&m);for(i=0; i<m; i++){scanf("%d",&a[i]);}sort(a,a+m);if(m==1){printf("%d\n",a[0]);continue;}ff=a[0];for(i=1; i<m; i++){count=1;while(a[i]==a[i-1] && i<m){count++;i++;}if(count>max){max=count;ff=a[i-1];}}printf("%d\n",ff);}return 0;}