1522: CF839 - A. Arya and Bran
[Creator : ]
Description
Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.
At first, Arya and Bran have $0$ Candies. There are $n$ days, at the $i$-th day, Arya finds $a_i$ candies in a box, that is given by the Many-Faced God. Every day she can give Branat most $8$ of her candies. If she don't give him the candies at the same day, they are saved for her and she can give them to him later.
Your task is to find the minimum number of days Arya needs to give Bran $k$ candies before the end of the $n$-th day. Formally, you need to output the minimum day index to the end of which $k$ candies will be given out (the days are indexed from $1$ to $n$).
Print $-1$ if she can't give him $k$ candies during $n$ given days.
Your task is to find the minimum number of days Arya needs to give Bran $k$ candies before the end of the $n$-th day. Formally, you need to output the minimum day index to the end of which $k$ candies will be given out (the days are indexed from $1$ to $n$).
Print $-1$ if she can't give him $k$ candies during $n$ given days.
Input
The first line contains two integers $n,k\ (1≤n≤100,\ 1≤k≤10000)$.
The second line contains $n$ integers $a_1,a_2,a_3,...,a_n\ (1≤a_i≤100)$.
The second line contains $n$ integers $a_1,a_2,a_3,...,a_n\ (1≤a_i≤100)$.
Output
If it is impossible for Arya to give Bran $k$ candies within $n$ days, print $-1$.
Otherwise print a single integer − the minimum number of days Arya needs to give Brankcandies before the end of the $n$-th day.
Otherwise print a single integer − the minimum number of days Arya needs to give Brankcandies before the end of the $n$-th day.
Sample 1 Input
2 3
1 2
Sample 1 Output
2
Arya can give Bran 17 candies in 3 days, because she can give him at most 8 candies per day.
Sample 2 Input
1 9
10
Sample 2 Output
-1
Arya can't give Bran 9 candies, because she can give him at most 8 candies per day and she must give him the candies within 1 day.