cswork / OA打开练习工作台

CiscoOA #9

Calculate Mean and Mode

简单可在线判题

考点(AI 标注)哈希计数

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.

输入格式

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

输出格式

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

样例 1

输入:

5
1 2 7 3 2

输出:

3 2

样例说明

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.