A - Sanitize Hands Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 100100

問題文

消毒液の入ったボトルがあり、その消毒液によってちょうど MM 本の手を消毒することができます。

NN 人の宇宙人が順に手の消毒を行いに来ます。
ii 人目 (1iN1\leq i\leq N) の宇宙人は HiH_i 本の手を持っており、それぞれ自身のすべての手を 11 回ずつ消毒したいと考えています。

何人目の宇宙人までがすべての手を消毒できるか求めてください。
ただし、ある宇宙人が消毒を始める時点で、自身のすべての手を消毒する分の消毒液が残っていなかったとしても、その宇宙人はその消毒液を使い切ってしまうものとします。

制約

  • 1N,M1001\leq N,M\leq 100
  • 1Hi1001\leq H_i\leq 100
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

NN MM
H1H_1 H2H_2 \ldots HNH_N

出力

何人目の宇宙人までが自身のすべての手を消毒できるか出力せよ。


入力例 1Copy

Copy
5 10
2 3 2 5 3

出力例 1Copy

Copy
3

次の手順で宇宙人は自身の手を消毒します。

  • 11 人目の宇宙人は自身の 22 本の手を消毒します。残りの消毒液によって、102=810-2=8 本の手を消毒できます。
  • 22 人目の宇宙人は自身の 33 本の手を消毒します。残りの消毒液によって、83=58-3=5 本の手を消毒できます。
  • 33 人目の宇宙人は自身の 22 本の手を消毒します。残りの消毒液によって、52=35-2=3 本の手を消毒できます。
  • 44 人目の宇宙人は 55 本の手を持っていますが、消毒液は 33 本分しかないため消毒液を使い切り、かつ自身のすべての手を消毒できません。

よって、33 人目の宇宙人までが自身のすべての手を消毒できるため、33 を出力します。


入力例 2Copy

Copy
5 10
2 3 2 3 5

出力例 2Copy

Copy
4

入力例 3Copy

Copy
1 5
1

出力例 3Copy

Copy
1

すべての宇宙人が自身の手を消毒することができます。

Score : 100100 points

Problem Statement

There is a bottle of disinfectant that can disinfect exactly MM hands.

NN aliens come one by one to disinfect their hands.
The ii-th alien (1iN1 \leq i \leq N) has HiH_i hands and wants to disinfect all of their hands once.

Determine how many aliens can disinfect all of their hands.
Here, even if there is not enough disinfectant left for an alien to disinfect all of their hands when they start, they will use up the remaining disinfectant.

Constraints

  • 1N,M1001 \leq N, M \leq 100
  • 1Hi1001 \leq H_i \leq 100
  • All input values are integers.

Input

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

NN MM
H1H_1 H2H_2 \ldots HNH_N

Output

Print the number of aliens who can disinfect all of their hands.


Sample Input 1Copy

Copy
5 10
2 3 2 5 3

Sample Output 1Copy

Copy
3

The aliens disinfect their hands in the following steps:

  • The first alien disinfects their two hands. The remaining disinfectant can disinfect 102=810-2=8 hands.
  • The second alien disinfects their three hands. The remaining disinfectant can disinfect 83=58-3=5 hands.
  • The third alien disinfects their two hands. The remaining disinfectant can disinfect 52=35-2=3 hands.
  • The fourth alien has five hands, but there is only enough disinfectant for three hands, so they use up the disinfectant without disinfecting all of their hands.

Thus, the first three aliens can disinfect all of their hands, so print 33.


Sample Input 2Copy

Copy
5 10
2 3 2 3 5

Sample Output 2Copy

Copy
4

Sample Input 3Copy

Copy
1 5
1

Sample Output 3Copy

Copy
1

All aliens can disinfect their hands.



2025-03-31 (Mon)
11:21:28 +00:00