#K41682. Medal Distribution
Medal Distribution
Medal Distribution
In this problem, you are given the number of participants in a competition and their scores. Medals are awarded to every participant whose score is among the top three unique scores. In case of ties, all participants with that score receive a medal. Formally, let (S) be the set of scores and let (U = { s : s \in S }) be the set of unique scores. After sorting (U) in descending order, if the first three (or fewer, if (|U| < 3)) elements are (u_1, u_2, u_3), then the number of medals is calculated by counting all occurrences of (u_1, u_2, u_3) in (S).
inputFormat
The input is given from standard input (stdin). The first line contains a non-negative integer (N), representing the number of participants. The second line contains (N) space-separated integers representing the scores of the participants. If (N = 0), the second line may be omitted.
outputFormat
Output to standard output (stdout) a single integer representing the total number of medals awarded.## sample
7
50 30 50 80 80 30 60
5