NYOJ-No. Statistics-254

Source: Internet
Author: User
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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.