Codeforces Round 428 (Div. 2)
A
Arya and Bran
Codeforces
900
原题
←B →
翻译中…

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 Bran at 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.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*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$).

翻译中…

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 Bran $*k*$ candies before the end of the $*n*$-th day.

翻译中…

Note

翻译中…

In the first sample, Arya can give Bran $3$ candies in $2$ days.

翻译中…

In the second sample, Arya can give Bran $17$ candies in $3$ days, because she can give him at most $8$ candies per day.

翻译中…

In the third sample, 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.

翻译中…

样例

Input #1
2 3
1 2
Output #1
2
InputCopy OutputCopy
Input #2
3 17
10 10 10
Output #2
3
InputCopy OutputCopy
Input #3
1 9
10
Output #3
-1
InputCopy OutputCopy
题目信息
题号
839A
时间限制
1 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。