## DMOPC '19 Contest 3 P1 - Mode Finding

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You are given numbers, . Output all the modes of this list on a single line from least to greatest. The mode of a list is/are the value(s) that appear(s) the most times relative to the other values in the list. It is guaranteed that at least one mode exists.

In all tests,

#### Input Specifications

The first line contains one number, .
The second line contains spaced integers, , the numbers in this list.

#### Output Specifications

On one line, output the modes of the numbers in increasing order.

#### Sample Input

10
9 2 9 6 8 7 1 3 9 6

#### Sample Output

9

• commented on June 8, 2020, 5:58 p.m.

Can someone check my submission? https://dmoj.ca/src/2135529 I've tried dozens of test cases and they all seem to work fine but I'm still getting WA.

• commented on June 8, 2020, 6:08 p.m.

You fail this case:

2
2 11
• commented on June 8, 2020, 6:22 p.m. edit 3

Thanks, fixed. The issue was that the numbers were being sorted alphabetically instead of numerically...

• commented on Feb. 21, 2020, 3:41 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Feb. 4, 2020, 11:32 p.m. edit 3

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Feb. 8, 2020, 3:50 p.m. edited

9 2 9 6 8 7 1 3 9 6

1: 1 occurrence

2: 1 occurrence

3: 1 occurrence

4: 0 occurrences

5: 0 occurrences

6: 2 occurrences

7: 1 occurrence

8: 1 occurrence

9: 3 occurrences

Therefore, 9 is the mode.

• commented on Feb. 4, 2020, 11:43 p.m.

yoh :D