No.1380 Borderline
Problem Statement
You held an entrance examination.
$\ N\ $ people took this exam, and the score of the $i\ $-th person $\ (1 \leq i \leq N)\ $ is $\ p_i\ $ points.
The capacity is $\ K\ $ people.
You choose a suitable borderline.
If the borderline is $\ B\ $ points $\ (0\leq B)\ $, the $\ i\ $-th person $\ (1 \leq i \leq N)\ $ passes if $\ p_i \geq B\ $, and fails otherwise.
When the borderline is set so that the number of people who pass does not exceed the capacity, find the maximum possible number of people who pass.
Input
$N\ K$ $p_1\ \ p_2\ \ \ldots\ \ p_N$
- $1 \leq N \leq 172$
- $1\leq K \leq N$
- $0\leq p_i \leq 400\ (1\leq i\leq N)$
- All input values are integers
Output
Output the maximum number of people satisfying the condition, followed by a newline.
Sample
Sample 1
Input
5 3 1 2 3 4 5
Output
3
If $B=3\ $, then $\ 3\ $ people pass, which satisfies the condition.
Sample 2
Input
6 3 1 2 2 2 3 3
Output
2
If $\ B=2\ $, the number of people who pass is $\ 5\geq K =3\ $, which is not acceptable.
The answer is $\ 2\ $, the number of people who pass when $\ B=3\ $.
Sample 3
Input
5 3 100 100 100 100 100
Output
0
The number of people who pass may be $\ 0\ $.
Sample 4
Input
7 6 20 21 2 10 2 11 76
Output
5
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂