题目描述
Problem Description
Takahashi has decided to plan his sleep schedule for the next $N$ days. On the $i$-th day, he plans to sleep for $t_i$ minutes.
Takahashi will become sleep-deprived if the total sleep time over any consecutive three days is less than $K$ minutes. Specifically, if $x \geq 3$, and the total sleep time on the $x-2$-th, $x-1$-th, and $x$-th days is less than $K$, he will become sleep-deprived on the $x$-th day. He does not become sleep-deprived if the total is exactly $K$.
Given Takahashi's planned sleep schedule, determine if he will become sleep-deprived, and if so, on which day he first becomes sleep-deprived.
Takahashi will not become sleep-deprived on the 1st and 2nd days. Also, since Takahashi only takes naps, you do not need to consider sleep that spans across days.
Input Format
The input is given from the standard input in the following format:
$N$ $K$ $t_1$ $t_2$ : $t_N$
- The first line contains the number of days $N (3 \leq N \leq 10^5)$ and the sleep-deprivation threshold $K (0 \leq K \leq 4,320)$, separated by a space.
- The next $N$ lines contain the planned sleep time for each day, where the $i$-th line contains an integer $t_i (0 \leq t_i \leq 1,440)$.
Output Format
If Takahashi does not become sleep-deprived during the $N$ days, output $-1$ on a single line. If he does become sleep-deprived, output the first day he becomes sleep-deprived on a single line.
Sample Input and Output
Sample Input #1
5 1080
300
420
420
180
360
Sample Output #1
4
Sample Input #2
5 180
60
60
60
60
60
Sample Output #2
-1
Sample Input #3
5 4230
360
360
360
360
360
Sample Output #3
3
Notes/Hints
Sample Explanation 1
The total sleep time on the 2nd, 3rd, and 4th days is 1020 minutes, which is less than $K$. There are no previous days where Takahashi became sleep-deprived. Therefore, Takahashi first becomes sleep-deprived on the 4th day.
Sample Explanation 2
Note that Takahashi does not become sleep-deprived if the total sleep time over three days is exactly $K$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分