NY-254-number statistics

Source: Internet
Author: User

Number statistics
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

1
5
12345 456 45 78 78

Sample output

78

 

Code:

 

# Include <cstdio> # include <algorithm> # include <iostream> # include <cstring> using namespace std; int main () {int max = 0, a [200003]; int n, m, I, ac; int count = 0; scanf ("% d", & n); while (n --) {scanf ("% d ", & m); for (I = 1; I <= m; I ++) scanf ("% d", & a [I]); max = 1; // The maximum value is at least 1 sort (a + 1, a + m + 1 ); // sort the numbers from 1 to m in the following Table // for (I = 1; I <= m; I ++) // printf ("% d", a [I]); // printf ("\ n = \ n"); if (m = 1) {printf ("% d \ n", a [1]); continue;} ac = a [1]; for (I = 2; I <= m ;) {count = 1; while (a [I] = a [I-1] & I <= m) // compare the number of I and the previous one, if not, keep accumulating {count ++; I ++;} if (count> max) // The maximum number of records and the corresponding number {max = count; ac = a [I-1];} I ++; // go to another number} printf ("% d \ n", ac);} 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.