P25484 [AtCoder] [ABC022A] Best Body
入门
题目描述

Problem Description

Takahashi has a body type that easily gains and loses weight. He decided to record his weight changes over $ N $ days.

Takahashi's weight on the first day was $ W $ kilograms. The weight change on the $ i $th day ($2 \leq i \leq N$) was $ A_i $ kilograms (where $ A_i $ can be negative). That is, if the weight on the $ i-1 $th day was $ X $ kilograms, then the weight on the $ i $th day was $ X + A_i $ kilograms.

By the way, according to Takahashi's personal values, a body weight between $ S $ kilograms and $ T $ kilograms (inclusive) is considered "best body".

Determine the number of days during the $ N $ days of recording when Takahashi had a best body.

Input Format

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

$ N $ $ S $ $ T $ $ W $ $ A_2 $ $ A_3 $ : $ A_N $

  • The first line contains the number of days Takahashi recorded his weight, an integer $N (2 \leq N \leq 1,000)$, and the values $S, T (1 \leq S \leq T \leq 10^5)$ that define the best body range, separated by spaces.
  • The second line contains an integer $W (1 \leq W \leq 10^5)$, representing Takahashi's weight on the first day.
  • The next $ N-1 $ lines contain integers $A_{i+1} (-10^5 \leq A_{i+1} \leq 10^5)$, representing the weight change on the $ i+1 $th day.
  • Takahashi's weight will never drop below $ 0 $ kilograms.

Output Format

Output the number of days Takahashi had a best body in one line. Ensure a newline at the end of the output.

Sample Input and Output

Sample Input #1

5 60 70
50
10
10
10
10

Sample Output #1

2

Sample Input #2

5 50 100
120
-10
-20
-30
70

Sample Output #2

2

Notes/Hints

Sample Explanation 1

Writing down Takahashi's weight from the first day in order gives $ 50, 60, 70, 80, 90 $. Therefore, Takahashi only had a best body on the 2nd and 3rd days.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 60 70 50 10 10 10 10
样例输出
2