#K73967. Fruit Crate Grading
Fruit Crate Grading
Fruit Crate Grading
You are given a crate containing fruits that each have an integer grade. The overall grade of the crate is determined by the most frequently occurring grade. If there is a unique grade that appears more times than any other, then the crate's grade is that number. Otherwise (if there is a tie for the highest frequency or if the crate is empty), the crate is considered mixed.
Formally, let the crate contain grades (a_1, a_2, \ldots, a_n). If there exists a grade (x) such that (#{i : a_i = x} > #{i : a_i = y}) for every (y \neq x), then output (x) (as a string). Otherwise, output mixed
.
inputFormat
The input is given via standard input. The first line contains a single integer (n) ((n \ge 0)) representing the number of fruits in the crate. If (n > 0), the second line contains (n) space-separated integers indicating the grades of the fruits. If (n = 0), no further input is provided.
outputFormat
Print a single line to standard output containing the crate grade. This must be the unique most frequent grade (as a string) if it exists, or the word mixed
if there is a tie or if the crate is empty.## sample
5
3 3 3 3 3
3