C. 转班 / Change Schools

    传统题 2000ms 256MiB

转班 / Change Schools

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

Currently, AtCoder High School has KK classes and NN students, and the ii-th (1≤i≤N)(1\le i\le N) student belongs to the AiA_i-th class.

Takahashi is transferring to AtCoder High School in September. At that time, he can choose any one class among the KK classes and belong to that class.

He will be sad if there is a class with more students belonging to it than the class he belongs to. Otherwise, he will be happy.

Find how many classes make him happy if he belongs to them.

Constraints

  • 1≤N≤2×1051\le N\le 2\times 10^5
  • 1≤K≤N1\le K\le N
  • 1≤Ai≤K (1≤i≤N)1\le A_i\le K\ (1\le i\le N)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN KK
  • A1A_1 A2A_2 …\ldots ANA_N

Output

Output the number of classes satisfying the condition.

8 5
3 3 5 5 4 4 3 2
3

For example, if Takahashi chooses the fifth class and belongs to it, the number of students belonging to the fifth class becomes 33. Then, he will be happy since there is no class with more than three students belonging to it.

On the other hand, for example, if he chooses the first class and belongs to it, the number of students belonging to the first class becomes 11. Then, he will be sad since three students belong to the third class.

He will be happy if and only if he chooses the third, fourth, or fifth class, so output 3.

6 1
1 1 1 1 1 1
1

It is possible that AtCoder High School has only one class.

14 8
6 1 5 3 8 4 3 4 3 5 1 2 5 1
4

ABC473 赛后模拟赛 ✅

未参加
状态
已结束
规则
IOI
题目
7
开始于
2026-8-29 21:40
结束于
2026-9-12 21:40
持续时间
336 小时
主持人
参赛人数
45