問題一覧 > 通常問題

No.1380 Borderline

レベル : / AI推定難易度 : 140 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 188
作問者 : Mitarushi / テスター : 蜜蜂
お気に入りにしたユーザー ProblemId : 5895 / 自分の提出
問題文最終更新日: 2021-02-08 08:51:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
灘高入試コンテスト2021 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。