P25287 [AtCoder] Bullet of Flame
普及
题目描述

Problem Description

Mr. Takahashi from GMO Internet loves shooting.

Now, Mr. Takahashi is about to shoot a flame bullet with power $ P $ towards $ N $ layers of walls.

The thickness of these $ N $ walls, from the nearest to the farthest, is $ A_1, A_2, ..., A_N $, and the bullet Mr. Takahashi shoots will first collide with the wall of thickness $ A_1 $.

When a bullet with power $ p $ collides with a wall of thickness $ x $, the following happens:

  • If $ p $ is greater than or equal to $ x $: The bullet penetrates the wall, and its power decreases by $ x $ before colliding with the next wall.
  • If $ p $ is less than $ x $: The bullet cannot penetrate the wall and stops.

How many walls will the bullet Mr. Takahashi shoots penetrate?

Input Format

The input is given from the standard input in the following format:

$ N $ $ P $ $ A_1 $ $ A_2 $ $ ... $ $ A_N $

Output Format

Output the number of walls the bullet Mr. Takahashi shoots will penetrate.

Sample Input and Output

Sample Input #1

4 10
2 6 3 2

Sample Output #1

2

Sample Input #2

2 10
1 9

Sample Output #2

2

Sample Input #3

1 100
1

Sample Output #3

1

Notes/Hints

Constraints

  • All inputs are integers.
  • $1 \leq N \leq 40$
  • $1 \leq P \leq 100$
  • $1 \leq A_i \leq 100$

Sample Explanation 1

The bullet with power $ 10 $ shot penetrates $ 2 $ walls as follows:
- First, it penetrates the wall of thickness $ 2 $, reducing its power to $ 8 $.
- Then, it penetrates the wall of thickness $ 6 $, reducing its power to $ 2 $.
- The next wall has a thickness of $ 3 $, so no further walls are penetrated.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 10 2 6 3 2
样例输出
2