Shandong University of Technology ACM platform answers about C language 1294 votes

Source: Internet
Author: User

Ballot count

Time Limit: 1000 ms Memory limit: 65536 K any questions? Click Here ^_^ The Student Union Chairman of a school is elected by a vote of all the students. A total of m candidates are registered for election, ranging from 1 to m (0 <m <1000 ), there are n students (0 <n <30000) in the school, and each student can vote. However, each person can only vote for one vote, and only one candidate can be selected for each vote. Please design a program to calculate which candidate gets the highest votes and how many votes you get. Enter the number of candidates m and number of students n in the first line, separated by spaces;
Enter the numbers of candidates selected by each student. Output the candidate number with the most votes in the first row;
The second row outputs the number of votes the candidate receives. Sample Input
3 101 2 3 2 3 1 3
Sample output
34
# Include
Void main ()
{
Int I, j, max, a [1, 1001], m, n, k;
Scanf ("% d \ n", & I, & j );
For (m = 1; m <= I; m ++)
{
A [m] = 0;
}
For (n = 1; n <= j; n ++)
{
Scanf ("% d", & k );
A [k] ++;
}
Max = 0;
K = 0;
For (m = 1; m <= I; m ++)
{
If (a [m]> max)
{
Max = a [m];
K = m;
}
}
Printf ("% d \ n", k );
Printf ("% d", max );
}

Related Article

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.