#ABC473C. 转班 / Change Schools
转班 / Change Schools
Problem Statement
Currently, AtCoder High School has classes and students, and the -th student belongs to the -th class.
Takahashi is transferring to AtCoder High School in September. At that time, he can choose any one class among the 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
- All input values are integers.
Input
The input is given from Standard Input in the following format:
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 . 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 . 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
- Source: AtCoder ABC 473 C
相关
在下列比赛中: