103631: [Atcoder]ABC363 B - Japanese Cursed Doll

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:10 Solved:0

Description

Score : $200$ points

Problem Statement

There are $N$ people, and the current hair length of the $i$-th person $(1 \leq i \leq N)$ is $L_i$.
Each person's hair grows by $1$ per day.

Print the number of days after which the number of people whose hair length is at least $T$ becomes $P$ or more for the first time.
If there are already $P$ or more people whose hair length is at least $T$ now, print $0$.

Constraints

  • $1 \leq N \leq 100$
  • $1 \leq L_i \leq 100$
  • $1 \leq T \leq 100$
  • $1 \leq P \leq N$
  • All input values are integers.

Input

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

$N$ $T$ $P$
$L_1$ $L_2$ $\ldots$ $L_N$

Output

Print the number of days after which the number of people whose hair length is at least $T$ becomes $P$ or more for the first time. If this condition is already satisfied now, print $0$.


Sample Input 1

5 10 3
3 11 1 6 2

Sample Output 1

7

There are five people, and their current hair lengths are $3, 11, 1, 6, 2$, so there is one person whose hair length is at least $10$.

After seven days, the hair lengths of the people will be $10, 18, 8, 13, 9$, respectively, and there will be three people whose hair length is at least $10$.
After six days, there are only two people whose hair length is at least $10$, not satisfying the condition, so print $7$.


Sample Input 2

2 5 2
10 10

Sample Output 2

0

Since there are already two people whose hair length is at least $5$ now, satisfying the condition, so print $0$.


Sample Input 3

3 10 1
1 2 3

Sample Output 3

7

Output

得分:200分

问题陈述

有$N$个人,第$i$个人($1 \leq i \leq N$)的当前头发长度是$L_i$。
每个人的头发每天增长$1$。

打印出头发长度至少为$T$的人数达到$P$或更多的人数首次出现的天数。
如果已经有$P$个或更多的人头发长度至少为$T$,则打印$0$。

约束条件

  • $1 \leq N \leq 100$
  • $1 \leq L_i \leq 100$
  • $1 \leq T \leq 100$
  • $1 \leq P \leq N$
  • 所有输入值都是整数。

输入

输入从标准输入以下格式给出:

$N$ $T$ $P$
$L_1$ $L_2$ $\ldots$ $L_N$

输出

打印头发长度至少为$T$的人数达到$P$或更多的人数首次出现的天数。 如果这个条件现在已经满足,则打印$0$。


示例输入1

5 10 3
3 11 1 6 2

示例输出1

7

有五个人,他们当前的头发长度分别是$3, 11, 1, 6, 2$,所以有一个人的头发长度至少为$10$。

经过七天,人们的头发长度将分别是$10, 18, 8, 13, 9$,将会有三个人的头发长度至少为$10$。
六天后,只有两个人的头发长度至少为$10$,不满足条件,所以打印$7$。


示例输入2

2 5 2
10 10

示例输出2

0

因为现在已经有两个人头发长度至少为$5$,满足条件,所以打印$0$。


示例输入3

3 10 1
1 2 3

示例输出3

7

加入题单

上一题 下一题 算法标签: