NYOJ286 (map)

Source: Internet
Author: User

NYOJ286 (map)

Question meaning:

There are a large number of species in the virgin forest of the beautiful daxing'anling district. The list of unrecorded primitive animals is included in the animal data provided by the surveyors. Scientists want to determine which animal in the forest has the largest number, but because the data is too large, scientists can't stand it at last. They want to ask your ACMer for help.

 

Enter the number of animal names N (1 <= N <= 10000) In the first line, and then enter N strings in the next N lines to indicate the animal name (the string length cannot exceed 10, all strings are lowercase letters and only one group of test data is available ). Output the names and quantities of the most animals among them, and separate them with spaces (data ensures that there are no more than two types of animals ). Sample Input
10boarpigsheepgazellesheepsheepalpacaalpacamarmotmole
Sample output
sheep 3
Question Analysis:Map application.

 

 

AC code:

# Include
# Include
# Include
Using namespace std;
String s [10001];
Int main ()
{
Int n;
While (cin> n ){
Map Num;
For (int I = 0; I Cin> s [I];
Num [s [I] ++;
}
String ss; int k = 0;
For (int I = 0; I If (k K = num [s [I];
Ss = s [I];
}
}
Cout < }
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.