304387: CF839A. Arya and Bran
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Arya and Bran
题意翻译
题目描述 布兰和他的姐姐艾莉亚来自同一所房子。布兰喜欢糖果,所以艾莉亚会给他一些糖果。 一开始,艾莉亚和布兰有0个糖果。一共有n天,在第i天,艾莉亚会在盒子里找到上帝赐予的ai颗糖果。她每天最多能给布兰8块糖。没有给完的糖果可以在以后给他。 你的任务是找出在第n天结束前,布兰最早在第几天可以得到k颗糖果。最后你只要将输出最早天数。如果布兰在第n天也不能得到k颗糖果则输出-1。 输入输出格式 输入格式: 第一行包含两个整数 $n$($1\le n\le 100$)和 $k$($1\le k\le 10000$) 第二行包含 $n$ 个整数 $a_1,a_2,a_3,\ldots,a_n$($1\leq a_i\leq100$) 输出格式: 输出应包含一个整数。如果布兰在 $n$ 天里可以得到 $k$ 颗糖果则输出最早天数,否则输出 `-1`。 说明 样例1中,艾莉亚在第二天时可以给布兰3颗糖果。 样例2中,艾莉亚可以在第三天时给布兰总共17颗糖果,因为她每天最多可以给他8颗糖果。 样例3中,艾莉亚不能给布兰9颗糖果,因为她每天最多可以给他8颗糖果,然而只有1天。题目描述
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.输入输出格式
输入格式
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 $ ).
输出格式
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.
输入输出样例
输入样例 #1
2 3
1 2
输出样例 #1
2
输入样例 #2
3 17
10 10 10
输出样例 #2
3
输入样例 #3
1 9
10
输出样例 #3
-1