cswork / OAOpen practice workspace

CiscoOA #9

Calculate Mean and Mode

EasyJudge-ready

Topics (AI-labelled)Hashing

Given an integer array, output two integers: the arithmetic mean rounded down, and the mode, the value that occurs most frequently. If there are several modes, return the smallest of them.

Original constraints: 1≤N≤100000, -10^9≤inputNums[i]≤10^9.

Input

The first line contains N; the second line contains N integers inputNums[i].

Output

Output mean mode in that order, as two integers separated by a space.

Example 1

Input:

5
1 2 7 3 2

Output:

3 2

Example notes

The mean is floor(sum(inputNums)/N); note that when a negative sum does not divide evenly, it rounds toward negative infinity. Use a frequency table to count the occurrences of each value, and take the smallest among the most frequent values.

Editorial

Loading solution…