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 );
}