Array practice 3


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C, C++, Python3

Mr Cleese teaches at the Royal Institute for Monty Python, and he is organising the student president election for this year.

The job itself is simple enough: Mr Cleese have \(N\) students, each with a unique student number from \(1\) to \(N\). Each of the students will write down a student number for which they'd like to become the next president. All you have to do is to count which student has the most votes, and announce the result of the election.

Since Mr Cleese is busy with his other duties at the moment, he has asked you to help him with this.

Input Specification

The first line will contain a single integer \(N\) (\(1 < N < 10000\)), indicating the number of students in the class. The students' student number will run from \(1\) to \(N\).

The following \(N\) lines will each contain a single integer. The \(i\)th line contains student \(i\)'s choice of the next president. If the vote is \(0\), it means that student did not vote.

Output Specification

There are two possible outcomes for the election:

  1. when a single student wins the majority of the vote (no less than \(N/2\)), then output in the first line Majority win, followed by another line with that student's number;

  2. when not a single student has the majority, but the student with most votes has at least \(N/3\) votes (minority win), then the first line of the output should be Minority win, then the second line that student's number;

  3. when not a single student has the majority nor minority, or two students won minority but has the same number of votes, output a single line with No winner!.

Sample Input 1

5
1
1
3
3
3

Sample Output 1

Majority win
3

Sample Input 2

6
1
1
0
4
5
5

Sample Output 2

No winner!

Sample Input 3

6
1
1
3
0
5
6

Sample Output 3

Minority win
1

Comments

There are no comments at the moment.