ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Арифметика > задача:


50359 - Mode of a Series

Гость
• Вопросы к жюри (1)

Задачи раздела

• 50392 - How much space
• 50330 - Find the average of n numbers
• 50297 - Divisible By Five
• 50394 - Water Bills
• 50363 - Class GPA Average
• 50398 - Sum of kth Anti-diagonal
• 50651 - Largest power of two
• 50388 - Number of Armstrong Num...
• 50359 - Mode of a Series
• 50440 - Call Center
• 50353 - Cube of the Largest number
• 50336 - Buying Carpets
• 50295 - Weighted Average
• 50296 - Total Discount Rate
• 50289 - Monthly Allowance
• 50559 - Faktoret e thjeshte te numrit
• 50568 - Llogaritesi i indeksit te mas...

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 4000/7000/7000/7000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Mode of a Series

Mode of a series of numbers is the number that occurs the most. For example, the mode of the following series:
    2 3 2 4 5 3 2 1
is 2. With three appearances in the list, it appears the most.

Write a program that is going to read a series of numbers then, it 's going to show the mode of the given series.

Input specification
The first line contains two numbers: the number of numbers (n) and the range of the numbers (m) where 2 ≤ n ≤ 100000 and 1 ≤ m ≤ 1000. The following line contains n space separated numbers where each of the numbers is between 1 and m .

Output specification
Show just one number which appears the most number of times in the series. If there are several numbers having the same (most) number of appearances, then show the smallest number as the mode of this series.

Sample Input:
  10 5
  4 1 1 5 3 2 4 3 3 1

Sample Output:
  1

Output Explanation:

  • 1 appears 3 times
  • 2 appears once
  • 3 appears 3 times
  • 4 appears 2 times
  • 5 appears once

Hence, 1 and 3 have both appeared three times and 1 is smaller; the answer is 1.

 

Для отправки решений необходимо выполнить вход.

www.contester.ru